diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-06-23 21:44:27 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-24 20:12:22 +0200 |
commit | 7a7c608a26f03abb1245ff83d4e25040ad09cb44 (patch) | |
tree | 52dc8af6ab4283dd58dd9716e6e08f383153cc29 /activerecord | |
parent | 497a0c3b00cc225215a8744bbf2a7e04c7297b7c (diff) | |
download | rails-7a7c608a26f03abb1245ff83d4e25040ad09cb44.tar.gz rails-7a7c608a26f03abb1245ff83d4e25040ad09cb44.tar.bz2 rails-7a7c608a26f03abb1245ff83d4e25040ad09cb44.zip |
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>
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index e84242601b..851e6d3718 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -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 |