1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Apply subsecond precision on assignment when using TZ aware attributes

When a time object was assigned to a datetime column, the decorator for
TZ aware attributes wouldn't call super, so when using a database
without support for subsecond precision, the nanosecond would not be
truncated, leading to the value being marked as changed.

Interestingly, this also shows our new implementation of dirty checking
to be more robust than the old one (with less code and better
performance! 🎉!!!)
This commit is contained in:
Sean Griffin 2015-09-24 15:16:06 -06:00
parent 370ef3e8bb
commit 20b177b78e

View file

@ -13,7 +13,7 @@ module ActiveRecord
set_time_zone_without_conversion(super)
elsif value.respond_to?(:in_time_zone)
begin
user_input_in_time_zone(value) || super
super(user_input_in_time_zone(value)) || super
rescue ArgumentError
nil
end