diff options
author | Johnny Holton <johnny@holton.co> | 2013-04-10 23:29:19 -0400 |
---|---|---|
committer | Johnny Holton <johnny@holton.co> | 2013-04-19 10:50:56 -0400 |
commit | 9de28419b1e6312e911eea0c315f326f498b195c (patch) | |
tree | d853fe8a146e497ed6a6b8f3e9135c9a0b2f70b5 /guides | |
parent | d098e1c24bc145e0cc14532348436e14dc46d375 (diff) | |
download | rails-9de28419b1e6312e911eea0c315f326f498b195c.tar.gz rails-9de28419b1e6312e911eea0c315f326f498b195c.tar.bz2 rails-9de28419b1e6312e911eea0c315f326f498b195c.zip |
destroys association records before saving/inserting new association records
fixes bug introduced by #3329
These are the conditions necessary to reproduce the bug:
- For an association, autosave => true.
- An association record is being destroyed
- A new association record is being created.
- There is a unique index one of the association's fields.
- The record being created has the same value as the record being
destroyed on the indexed field.
Before, the deletion of records was postponed until after all
insertions/saves. Therefore the new record with the identical value in
the indexed field caused a non-unique value error to be thrown at the database
level.
With this fix, the deletions happen first, before the insertions/saves.
Therefore the record with the duplicate value is gone from the database
before the new record is created, thereby avoiding the non-uniuqe value
error.
Diffstat (limited to 'guides')
0 files changed, 0 insertions, 0 deletions