This project is archived and is in readonly mode.
Bug with dirty models in integer fields
Reported by Felipe Giotto | December 5th, 2008 @ 05:26 PM | in 2.x
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!
Comments and changes to this ticket
-
Frederick Cheung December 7th, 2008 @ 02:54 PM
I wonder if is related to this thread ? I assume the column is marked as being nullable
-
Frederick Cheung December 21st, 2008 @ 11:30 AM
- 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/1415df8f49a19d469b9e2c15785db32eb312c000 was designed to address that.
Please reopen if you are still getting this with 2.1.2/2.2.2/edge
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>