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.

Bug with dirty models in integer fields

#1518

There's a problem with dirty models.

I can use the following example:

There's a model named Person, with name(string) and age(integer).

p = Person.first p.update_attributes :age => 0, :name => 'Felipe'

This SQL runs: UPDATE people SET age = 0, name = 'Felipe' WHERE id = 1 Then, I typed:

p.update_attributes :age => '', :name => 'John'

This SQL runs: UPDATE people SET name = 'John' WHERE id = 1

When the value changes from 0 to '' (supposed to be stored as nil), Rails didn't recognize it as a change!

Reported by Felipe Giotto · December 5th, 2008 @ 05:26 PM

State: duplicate
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Frederick Cheung
    Frederick Cheung

    I wonder if is related to this thread ? I assume the column is marked as being nullable

    December 7th, 2008 @ 02:54 PM

  2. Frederick Cheung
    Frederick Cheung
    • State changed from new to duplicate

    What version of rails were you using ? I could reproduce this in 2.1.0 but not in 2.1.2 or 2.2.2 or edge.

    This was definitely a problem in 2.1.0 but #433 Dirty doesn't track integers changing from 0 to null/1415df8f49a19d469b9e2c15785db32eb312c000 was designed to address that.

    Please reopen if you are still getting this with 2.1.2/2.2.2/edge

    December 21st, 2008 @ 11:30 AM