Optimistic locking on #destroy

Curtis Hawthorne
2008-12-27T19:52:51Z

Hi all,

I just noticed that optimistic locking doesn''t seem to affect #destroy
calls.  This is currently causing me problems because my
#after_destroy handlers can end up using stale data.  I could also see
it causing trouble if a model had some sort of ''do_not_delete''
flag
that was changed right after AR loaded the record.

So, it seems to me like #destroy should follow the same optimistic
locking logic as updates do.  That is, add the current lock version to
the WHERE clause and raise a StaleObjectError if the delete fails.

I''d be happy to write a patch to fix it, but I wanted to make sure
that I understood the issue correctly and that adding this behavior is
the correct approach.

Thanks!

Curtis H.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---