mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Your original TIME ZONE value on PostgreSQL is correctly restored now, after going through options :utc and then going back to :local
[#4950 state:committed] Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
committed by
José Valim
parent
497a0c3b00
commit
7a7c608a26
@@ -216,7 +216,10 @@ module ActiveRecord
|
||||
super(connection, logger)
|
||||
@connection_parameters, @config = connection_parameters, config
|
||||
|
||||
# @local_tz is initialized as nil to avoid warnings when connect tries to use it
|
||||
@local_tz = nil
|
||||
connect
|
||||
@local_tz = execute('SHOW TIME ZONE').first["TimeZone"]
|
||||
end
|
||||
|
||||
# Is this connection alive and ready for queries?
|
||||
@@ -929,9 +932,8 @@ module ActiveRecord
|
||||
# TIMESTAMP WITH ZONE types in UTC.
|
||||
if ActiveRecord::Base.default_timezone == :utc
|
||||
execute("SET time zone 'UTC'")
|
||||
else
|
||||
offset = Time.local(2000).utc_offset / 3600
|
||||
execute("SET time zone '#{offset}'")
|
||||
elsif @local_tz
|
||||
execute("SET time zone '#{@local_tz}'")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user