Igor Katson wrote:
>
> Hello!
>
> I am stuck when trying to delete an object, on which there are
> references. I have a database-level ON DELETE CASCADE rule, but when
> issuing Session.delete, it raises an IntegrityError, cause sqlalchemy
> first tries to SET NULL the references on all the children. If I use
> cascade='all, delete,...', it works, cause it issues a DELETE
> statement for ALL the children, and this is superfluous, cause I want
> the database to issue all the deletes with only one statement.
>
> Is it possible to use database-level cascade rules when issuing
> Session.delete instead of orm.relation(cascade)?

only for child objects that aren't loaded into the in-memory collection
already.  see
http://www.sqlalchemy.org/docs/05/mappers.html#using-passive-deletes . 
You can also expire() the parent object's collection to force the CASCADE
rule to process the collection in the case that it is loaded already.



--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to