aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorCarlos Kozuszko <carlos@insignia4u.com>2009-01-04 20:22:53 -0200
committerMichael Koziarski <michael@koziarski.com>2009-01-16 10:00:39 +1300
commitc891d685de9a729332836751c1293770b86a1b52 (patch)
treed17e38e746c52eca357e35892ec180236715495f /activerecord/lib
parent9bcf01b23c25e640da7908ac8b1b49fbf7d2e51a (diff)
downloadrails-c891d685de9a729332836751c1293770b86a1b52.tar.gz
rails-c891d685de9a729332836751c1293770b86a1b52.tar.bz2
rails-c891d685de9a729332836751c1293770b86a1b52.zip
Fixing bug on ActiveRecord::Dirty#field_changed? for nullable numeric columns, NULL gets stored in database for blank (i.e. '') values. Only integer columns were considered.
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1692 state:committed]
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/dirty.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/dirty.rb b/activerecord/lib/active_record/dirty.rb
index 4c899f58e5..4a2510aa63 100644
--- a/activerecord/lib/active_record/dirty.rb
+++ b/activerecord/lib/active_record/dirty.rb
@@ -151,8 +151,8 @@ module ActiveRecord
def field_changed?(attr, old, value)
if column = column_for_attribute(attr)
- if column.type == :integer && column.null && (old.nil? || old == 0) && value.blank?
- # For nullable integer columns, NULL gets stored in database for blank (i.e. '') values.
+ if column.number? && column.null && (old.nil? || old == 0) && value.blank?
+ # For nullable numeric columns, NULL gets stored in database for blank (i.e. '') values.
# Hence we don't record it as a change if the value changes from nil to ''.
# If an old value of 0 is set to '' we want this to get changed to nil as otherwise it'll
# be typecast back to 0 (''.to_i => 0)