aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-03-29 22:19:26 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-03-29 22:19:26 +0000
commit81286f858770e0b95e15af37f19156b044ec6a95 (patch)
tree752aaac65d38f75216b74cfb78492af1fd52a476 /activerecord/lib/active_record
parenteece9b4e8a9b46a909af424538c4cc55d78b0142 (diff)
downloadrails-81286f858770e0b95e15af37f19156b044ec6a95.tar.gz
rails-81286f858770e0b95e15af37f19156b044ec6a95.tar.bz2
rails-81286f858770e0b95e15af37f19156b044ec6a95.zip
Dirty typecasts attribute values before comparison, if possible. Closes #11464 [Russell Norris, mroch]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9139 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/dirty.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/dirty.rb b/activerecord/lib/active_record/dirty.rb
index a9ae2b148c..4b65545851 100644
--- a/activerecord/lib/active_record/dirty.rb
+++ b/activerecord/lib/active_record/dirty.rb
@@ -91,7 +91,12 @@ module ActiveRecord
old = read_attribute(attr)
# Remember the original value if it's different.
- changed_attributes[attr] = old unless old == value
+ typecasted = if column = column_for_attribute(attr)
+ column.type_cast(value)
+ else
+ value
+ end
+ changed_attributes[attr] = old unless old == typecasted
end
# Carry on.