diff options
author | Jack Christensen <jack@jackchristensen.com> | 2010-01-23 20:16:29 -0600 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2010-01-25 20:57:07 -0600 |
commit | c5b652f3d25ef92ae0f67551464fb03bda6aeb4f (patch) | |
tree | 9d6708a81f3c9b72a65ead87a0aeb82fda493978 /activerecord/lib | |
parent | 64f8c87b1dab9bc9b6324fd6a3d77945f4b62821 (diff) | |
download | rails-c5b652f3d25ef92ae0f67551464fb03bda6aeb4f.tar.gz rails-c5b652f3d25ef92ae0f67551464fb03bda6aeb4f.tar.bz2 rails-c5b652f3d25ef92ae0f67551464fb03bda6aeb4f.zip |
PostgreSQLAdapter: set time_zone to UTC when Base.default_timezone == :utc so that Postgres doesn't incorrectly offset-adjust values inserted into TIMESTAMP WITH TIME ZONE columns [#3777 state:resolved]
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 1d52c5ec14..b3ce8c79dd 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -998,7 +998,7 @@ module ActiveRecord configure_connection end - # Configures the encoding, verbosity, and schema search path of the connection. + # Configures the encoding, verbosity, schema search path, and time zone of the connection. # This is called by #connect and should not be called manually. def configure_connection if @config[:encoding] @@ -1010,6 +1010,10 @@ module ActiveRecord end self.client_min_messages = @config[:min_messages] if @config[:min_messages] self.schema_search_path = @config[:schema_search_path] || @config[:schema_order] + + # If using ActiveRecord's time zone support configure the connection to return + # TIMESTAMP WITH ZONE types in UTC. + execute("SET time zone 'UTC'") if ActiveRecord::Base.default_timezone == :utc end # Returns the current ID of a table's sequence. |