Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5517: pg_my_utc_default.patch

File pg_my_utc_default.patch, 1.3 kB (added by gerardo, 2 years ago)

Tell PostgreSQL and MySQL to use UTC as the default time zone when Rails is doing so.

  • activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

    old new  
    398398          if @config[:min_messages] 
    399399            execute("SET client_min_messages TO '#{@config[:min_messages]}'") 
    400400          end 
     401          if (Base.default_timezone == :utc) 
     402            execute("SET TIME ZONE 'UTC'") 
     403          end 
    401404        end 
    402405 
    403406        def last_insert_id(table, sequence_name) 
  • activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    old new  
    334334          end 
    335335          @connection.real_connect(*@connection_options) 
    336336          execute("SET NAMES '#{encoding}'") if encoding 
     337          if (Base.default_timezone == :utc) 
     338            execute("SET time_zone = UTC") 
     339          end 
    337340        end 
    338341 
    339342        def select(sql, name = nil)