On 7 Jun 2006, at 6:36 am, Chris Mear wrote:

A couple of weeks ago I noticed a bug with :dependent => :nullify on a has_many or has_one. When you delete the parent, the children's foreign keys are nullified, as expected. But when you do parent.child.delete or parent.children.clear, ActiveRecord actually deletes the child records, rather than just nullifying them.

In my eyes, if you've set :dependent => :nullify, you're saying that the child records should only ever be nullified, not deleted. The behaviour I'm seeing seems to be a hang over from when setting :dependent always meant 'delete/destroy the children'.

However, I realise that maybe this is just my interpretation of what the :dependent => :nullify option is supposed to do. So I'd be interested to hear what everyone else thinks.

I've written up the problem, with a patch, here:

http://dev.rubyonrails.org/ticket/5209

Any thoughts/opinions on this yet? Sorry to spam, but it's potentially destructive behaviour, and I'm keen to see it resolved one way or the other.

Thanks,
Chris

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to