Skip to content

Commit

Permalink
Your original TIME ZONE value on PostgreSQL is correctly restored now…
Browse files Browse the repository at this point in the history
…, after going through options :utc and then going back to :local

[rails#4950 state:committed]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
spastorino authored and josevalim committed Jun 24, 2010
1 parent 497a0c3 commit 7a7c608
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ def initialize(connection, logger, connection_parameters, config)
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?
Expand Down Expand Up @@ -929,9 +932,8 @@ def configure_connection
# 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

Expand Down

0 comments on commit 7a7c608

Please sign in to comment.