This project is archived and is in readonly mode.
destroy with optimistic locking doesn't set destroyed? flag
-
Svelix
Confirmed.
-
Neeraj Singh
- Milestone set to 3.x
- State changed from new to open
- Importance changed from to Low
@Jacob thanks for the patch and the test. It is a good patch however I would recommend following changes
-
as per your patch if a new record is destroyed then destroyed flag would be set to true. That should not happen. Please add a test so that Person.new.destroy.destroyed? returns false
-
change
toassert_equal true, p1.destroyed?
. I know you just followed what was there a line above. If you want you can fix that line too.assert p1.destroyed?
-
jlewalle (at gmail)
No problem... about the destroy of a new record, that doesn't appear to be the behavior of the non-locking destroy:
def destroy if persisted? self.class.unscoped.where(self.class.arel_table[self.class.primary_key].eq(id)).delete_all end @destroyed = true freeze endJust wanna make sure I understand things.
I'll change the asserts.. thanks for the feedback!
-
José Valim
- Assigned user set to José Valim
Hey guys,
Actually, if destroy is called on a record which was not persisted? (a new_record?), it should raise an error. I believe Neeraj is already working on a patch for it. :)
-
Neeraj Singh
I will create a new ticket and will attach patch after this one is committed.
-
jlewalle (at gmail)
Awesome, let me know if you need anything else from me. Here's the patch with the cleaner assert's.
-
José Valim
Jacob, your patch does not apply here. Git complains the format is invalid. Could you please follow the conventions here?
http://rails.lighthouseapp.com/projects/8994/sending-patches
Thanks!
-
jlewalle (at gmail)
Ah ok... I verified this one works. Thanks for your patience. I've also got a github fork here:
-
Neeraj Singh
I am still not able to apply the *-flag3.patch.
However this commit http://github.com/jlewallen/rails/commit/c7d2a50309b4a74ffc3564c4b5... can be pulled .
-
jlewalle (at gmail)
Ah... well.. still weird the patch wasn't working. I'm able to apply with:
git am < optimistic-locking-destroyed-flag-3.patch
What's the error you see?
-
Neeraj Singh
Applying: Set destroyed=true in opt locking's destroy error: activerecord/lib/active_record/locking/optimistic.rb: does not match index error: activerecord/test/cases/locking_test.rb: does not match index Patch failed at 0001 Set destroyed=true in opt locking's destroy When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort". -
jlewalle (at gmail)
Can you give me the sha1 of the branch you're applying to?
-
Repository
- State changed from open to resolved
(from [8298bef72eac980e5a5abab12a9539c0ae1b8ceb]) Set destroyed=true in opt locking's destroy [#5058 destroy with optimistic locking doesn't set destroyed? flag state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/8298bef72eac980e5a5abab12a9539... -
Repository
(from [d10ecfefb8bd4461127f552f14970ad6b3df507f]) Set destroyed=true in opt locking's destroy [#5058 destroy with optimistic locking doesn't set destroyed? flag state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/d10ecfefb8bd4461127f552f14970a...
