This project is archived and is in readonly mode.
field_changed? should check also string columns for changes from nil to ''
Reported by Edgars Beigarts | August 27th, 2008 @ 12:42 AM | in 2.x
An empty string is treated as a null value in Oracle. So why not add " || column.type == :string" ?
def field_changed?(attr, old, value)
if column = column_for_attribute(attr)
if (column.type == :integer || column.type == :string) && column.null && (old.nil? || old == 0)
# For nullable integer 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)
value = nil if value.blank?
else
value = column.type_cast(value)
end
end
old != value
end
Comments and changes to this ticket
-
josh November 27th, 2008 @ 03:17 AM
- State changed from new to wontfix
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
- Nobody is watching this ticket.