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.

ActiveRecord 2.1 does not update db if text attrib modified with []=

#651

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

Reported by Steve Rawlinson · July 18th, 2008 @ 03:10 PM

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

Activity

  1. Pratik
    Pratik
    • 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'
    

    July 18th, 2008 @ 05:25 PM

  2. Steve Rawlinson
    Steve Rawlinson

    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.

    July 19th, 2008 @ 04:10 PM