Delete with cascade fails when MapperRules.createForeignKeys_? is true
When using Mapper, cascade deletes fail when foreign keys are enabled (i.e. MapperRules.createForeignKeys_? = _ => true)
When you try to delete the one side of the many-to-one relationship, you get a referential integrity constraint violation.
The problem is in OneToMany.delete_!. It attempts to delete the current object prior to deleting the oneToManyFields. Reversing the logic (deleting the oneToManyFields first should fix the problem.
The fk-delete-cascade branch in git://github.com/leedm777/lift-sample-app.git has a spec (ForeignKeySpecs) that demonstrates the problem.
I'm using Lift 2.3.
When you try to delete the one side of the many-to-one relationship, you get a referential integrity constraint violation.
The problem is in OneToMany.delete_!. It attempts to delete the current object prior to deleting the oneToManyFields. Reversing the logic (deleting the oneToManyFields first should fix the problem.
The fk-delete-cascade branch in git://github.com/leedm777/lift-sample-app.git has a spec (ForeignKeySpecs) that demonstrates the problem.
I'm using Lift 2.3.
Leave a comment
nafg: Thanks for getting this fixed!!!
I think there's a corner case your fix doesn't handle.
If all of the oneToMany fields successfully delete, but super.delete_! fails, then the oneToMany fields will be deleted, the record you're trying to delete will remain, and the method will return false.
Should I reopen, file a new ticket, or ignore it?
I think there's a corner case your fix doesn't handle.
If all of the oneToMany fields successfully delete, but super.delete_! fails, then the oneToMany fields will be deleted, the record you're trying to delete will remain, and the method will return false.
Should I reopen, file a new ticket, or ignore it?