Lighthouse has a new layout.
Prefer the old one? Return to the old layout,
and switch back any time from the link at the top of each page.
This project is archived and is in readonly mode.
field_changed? should check also string columns for changes from nil to ''
#911
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