mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix PostgreSQL TIMESTAMP WITH TIME ZONE to return ActiveSupport::Time
In an AR model a timestamptz attribute would return a ruby string and AR tests did not check for any type casting. Previous tests would pass only because an assert_equal was being used on a Time.utc object, which will parse the right side of the eq to a valid Time instance for comparision. switch to test instance of Time instead of ActiveSupport::TimeWithZone
This commit is contained in:
parent
b49a2a779b
commit
2cc09441c2
3 changed files with 8 additions and 4 deletions
|
@ -1,5 +1,10 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* Postgresql timestamp with time zone (timestamptz) datatype now returns a
|
||||
ActiveSupport::TimeWithZone instance instead of a string
|
||||
|
||||
*Troy Kruthoff*
|
||||
|
||||
* Added support for creating a table via Rails migration generator.
|
||||
For example,
|
||||
|
||||
|
|
|
@ -317,10 +317,6 @@ module ActiveRecord
|
|||
alias_type 'macaddr', 'text'
|
||||
alias_type 'uuid', 'text'
|
||||
|
||||
# FIXME: I don't think this is correct. We should probably be returning a parsed date,
|
||||
# but the tests pass with a string returned.
|
||||
register_type 'timestamptz', OID::Identity.new
|
||||
|
||||
register_type 'money', OID::Money.new
|
||||
register_type 'bytea', OID::Bytea.new
|
||||
register_type 'bool', OID::Boolean.new
|
||||
|
@ -329,6 +325,7 @@ module ActiveRecord
|
|||
alias_type 'float8', 'float4'
|
||||
|
||||
register_type 'timestamp', OID::Timestamp.new
|
||||
register_type 'timestamptz', OID::Timestamp.new
|
||||
register_type 'date', OID::Date.new
|
||||
register_type 'time', OID::Time.new
|
||||
|
||||
|
|
|
@ -573,6 +573,7 @@ _SQL
|
|||
|
||||
@first_timestamp_with_zone = PostgresqlTimestampWithZone.find(1)
|
||||
assert_equal Time.utc(2010,1,1, 11,0,0), @first_timestamp_with_zone.time
|
||||
assert_instance_of Time, @first_timestamp_with_zone.time
|
||||
ensure
|
||||
ActiveRecord::Base.default_timezone = old_default_tz
|
||||
ActiveRecord::Base.time_zone_aware_attributes = old_tz
|
||||
|
@ -590,6 +591,7 @@ _SQL
|
|||
|
||||
@first_timestamp_with_zone = PostgresqlTimestampWithZone.find(1)
|
||||
assert_equal Time.utc(2010,1,1, 11,0,0), @first_timestamp_with_zone.time
|
||||
assert_instance_of Time, @first_timestamp_with_zone.time
|
||||
ensure
|
||||
ActiveRecord::Base.default_timezone = old_default_tz
|
||||
ActiveRecord::Base.time_zone_aware_attributes = old_tz
|
||||
|
|
Loading…
Reference in a new issue