diff options
author | Lilibeth De La Cruz <lilibethdlc@gmail.com> | 2013-01-25 04:14:27 -0400 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-01-26 16:57:33 +0000 |
commit | bc982cbcb34129ea2cfe8aa1f8e0b40e444e68db (patch) | |
tree | 645b9d67e452ff31e1b69b2643047a17b6bb1ed5 /activerecord/CHANGELOG.md | |
parent | 0b5d3f32732f637fe29848a3597852dce9662c6b (diff) | |
download | rails-bc982cbcb34129ea2cfe8aa1f8e0b40e444e68db.tar.gz rails-bc982cbcb34129ea2cfe8aa1f8e0b40e444e68db.tar.bz2 rails-bc982cbcb34129ea2cfe8aa1f8e0b40e444e68db.zip |
Fix handling of dirty time zone aware attributes
Previously, when `time_zone_aware_attributes` were enabled, after
changing a datetime or timestamp attribute and then changing it back
to the original value, `changed_attributes` still tracked the
attribute as changed. This caused `[attribute]_changed?` and
`changed?` methods to return true incorrectly.
Example:
in_time_zone 'Paris' do
order = Order.new
original_time = Time.local(2012, 10, 10)
order.shipped_at = original_time
order.save
order.changed? # => false
# changing value
order.shipped_at = Time.local(2013, 1, 1)
order.changed? # => true
# reverting to original value
order.shipped_at = original_time
order.changed? # => false, used to return true
end
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 6f3bd50f9a..9e22be1b94 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,33 @@ ## Rails 4.0.0 (unreleased) ## +* Fix handling of dirty time zone aware attributes + + Previously, when `time_zone_aware_attributes` were enabled, after + changing a datetime or timestamp attribute and then changing it back + to the original value, `changed_attributes` still tracked the + attribute as changed. This caused `[attribute]_changed?` and + `changed?` methods to return true incorrectly. + + Example: + + in_time_zone 'Paris' do + order = Order.new + original_time = Time.local(2012, 10, 10) + order.shipped_at = original_time + order.save + order.changed? # => false + + # changing value + order.shipped_at = Time.local(2013, 1, 1) + order.changed? # => true + + # reverting to original value + order.shipped_at = original_time + order.changed? # => false, used to return true + end + + *Lilibeth De La Cruz* + * When `#count` is used in conjunction with `#uniq` we perform `count(:distinct => true)`. Fix #6865. |