On Jun 5, 2007, at 11:20 AM, lingo wrote:
> now it looks like: > Parent_table = sa.Table('Parent', metadata, autoload=True) > Child_table = sa.Table('Child', metadata, autoload=True) > > orm.mapper(Parent,Parent_table, properties={ > 'Children' : relation(Child, cascade="save-update") > } > ) > > orm.mapper(Child,Child_table, properties={ > 'Parent' : relation(Parent, cascade="save-update") > } > ) > > I switched on debugging on sqlalchemy to see what happens when i try > to delete a "parent" object. > > The weird thing is (and probably was also the case before) that the > parent gets deleted, and the child isn't. After parent-deletion the > foreign key on the child is set to null (or empty). This is not the > expected behavior when using "on delete=restrict", this is more like > "on delete=set null". you need to set your cascade to "all, delete-orphan". this includes "delete" cascade underneath "all" which cascades a parent "delete" to all attached children, and delete-orphan will prevent any Child objects from remaining with no Parent in the event that the Child is just detached from its Parent. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---