
Deleting parent fails after deleting all children. (unless a .reload is done on parent)
Reported by dev2 | September 10th, 2010 @ 10:04 AM
This ticket is being submitted at the request of dkubb on freenode/datamapper.
The issue is with deleting a record that has child records. Even after deleting all of the parents records in the join table the destroy still fails. I was able to work around this (under the advice of dkubb) by adding a .reload before finally destroying the parent.
In the mysql console I can see the constraings on the join table. From the console I am able to successfully delete the child records and then the parent.
@doc = Document.get(1)
begin
Document.transaction do
#this is a simple app, only 2 models and one Resource/model
#the following executes successfully
unless @doc.document_tags.destroy
raise 'document tags failed to be destroyed'
end
#the following fails unless its changed to @doc.reload.destroy
unless @doc.destroy
raise 'document destroy failed'
end
end
rescue StandardError => e
puts e
end
Please contact me on freenode if you require any additional information. -dev2
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) October 29th, 2010 @ 03:51 PM
- State changed from new to confirmed
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »