This project is archived and is in readonly mode.
ActiveRecord 2.1 does not update db if text attrib modified with []=
Reported by Steve Rawlinson | July 18th, 2008 @ 03:10 PM | in 2.x
For example:
o = MyObject.find(1)
o.mytext_attrib = "xxxxx"
o.save
Works fine. However ...
o.mytext_attrib[1] = 'X'
o.mytext_attrib => "xXxxx"
o.save => true
o.reload
o.mytext_attrib => "xxxxx"
Checking the SQL log, no attempt is made to modify the row in the table.
If I also change another attrib and save, it updates the other modified
attrib, but not the text attrib modified with []=.
This behaviour has only started since moving to 2.1 from 2.0.2.
Hope that helps somebody.
steve
Comments and changes to this ticket
-
Pratik July 18th, 2008 @ 05:25 PM
- State changed from new to invalid
- Tag cleared.
If your app rely heavily on this, it might be advisable to disable partial updates. Otherwise, you'll need to do the following :
o.mytext_attrib_will_change! o.mytext_attrib[1] = 'X'
-
Steve Rawlinson July 19th, 2008 @ 04:10 PM
Hmm. I think this is a bug. Partial updates is a great feature but if it
doesn't notice when an attrib is changed by some (perfectly legitimate)
means other than direct assignment should it be on by default?
I've turned it off, thanks for the tip.
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>