Michael Bayer wrote: > On Jun 29, 2007, at 10:38 AM, Huy Do wrote: > > >> Hi, >> >> How do I configure my mapper/table to leave the cascade up to my >> database. i.e I don't want SA to auto update or delete my child >> objects >> when I delete or update my parent object. >> >> > > > you are probably looking for "passive_deletes=True" on your > relations. you can also prevent SQLAlchemy from marking child items > as deleted by just not using "delete" cascade, but you cannot prevent > it from updating the foreign key of child items with NULL..also if a > delete cascade takes place, the session's view of objects will be > incorrect if one of the deleted child items is still present in the > session...so best to leave your cascade matching that of the database. > Yeah...but I really don't want SA doing the delete or update for me, when my database can do it. I guess that's the price for using the ORM. > the passive_deletes flag will just prevent it from defensively > loading in child items upon delete which is probably what youre > looking for. > This is my problem. I have cascade delete on one of my tables, and when i try to delete a record, i get the null not allowed in foreign key error. This happens because SA is trying to update my child records when i delete the main record. I was hoping to use Relation(...cascade="expunge"), but it doesn't seem to do what I thought. I just want SA not to do an update on the child records (or anything else on the child records), just delete the main record.
Thanks Huy > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---