aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb10
-rw-r--r--activerecord/test/migration_test.rb10
3 files changed, 8 insertions, 14 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index b76c16792c..cbd928ac65 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* PostgreSQL: remove DateTime -> Time downcast. Warning: do not enable translate_results for the C bindings if you have timestamps outside Time's domain. [Jeremy Kemper]
+
* find_or_create_by_* takes a hash so you can create with more attributes than are in the method name. For example, Person.find_or_create_by_name(:name => 'Henry', :comments => 'Hi new user!') is equivalent to Person.find_by_name('Henry') || Person.create(:name => 'Henry', :comments => 'Hi new user!'). #7368 [Josh Susser]
* Make sure with_scope takes both :select and :joins into account when setting :readonly. Allows you to save records you retrieve using method_missing on a has_many :through associations. [Koz]
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index c4bd2c8a04..3fb1655526 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -451,8 +451,6 @@ module ActiveRecord
case res.type(cel_index)
when BYTEA_COLUMN_TYPE_OID
column = unescape_bytea(column)
- when TIMESTAMPTZOID, TIMESTAMPOID
- column = cast_to_time(column)
when NUMERIC_COLUMN_TYPE_OID
column = column.to_d if column.respond_to?(:to_d)
end
@@ -579,14 +577,6 @@ module ActiveRecord
# and we can't know the value of that, so return nil.
return nil
end
-
- # Only needed for DateTime instances
- def cast_to_time(value)
- return value unless value.class == DateTime
- v = value
- time_array = [v.year, v.month, v.day, v.hour, v.min, v.sec, v.usec]
- Time.send(Base.default_timezone, *time_array) rescue nil
- end
end
end
end
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index f5b13f6c99..edbea9aa78 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -303,10 +303,12 @@ if ActiveRecord::Base.connection.supports_migrations?
end
# Test DateTime column and defaults, including timezone.
- assert_equal DateTime, bob.moment_of_truth.class
- assert_equal DateTime.now.offset, bob.moment_of_truth.offset
- assert_not_equal 0, bob.moment_of_truth.offset
- assert_not_equal "Z", bob.moment_of_truth.zone
+ # FIXME: momemnt of truth is Time on 64-bit platforms.
+ if bob.moment_of_truth.is_a?(DateTime)
+ assert_equal DateTime.now.offset, bob.moment_of_truth.offset
+ assert_not_equal 0, bob.moment_of_truth.offset
+ assert_not_equal "Z", bob.moment_of_truth.zone
+ end
assert_equal TrueClass, bob.male?.class
assert_kind_of BigDecimal, bob.wealth