Optimistic locking on #destroy

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.


Curtis H.