Skip to content
Browse files

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>
  • Loading branch information...
1 parent 497a0c3 commit 7a7c608a26f03abb1245ff83d4e25040ad09cb44 @spastorino spastorino committed with josevalim Jun 23, 2010
Showing with 5 additions and 3 deletions.
  1. +5 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
8 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -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?
@@ -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

0 comments on commit 7a7c608

Please sign in to comment.
Something went wrong with that request. Please try again.