On 10/28/15 1:26 PM, Chris Wilson wrote: > OK, I hadn't thought of that, it might work but in fact I want to delete > a Cat when it has no Houses left (House -> Cat in this case, with > uselist=True instead of uselist=False as in the example above) and it's > not clear that delete-orphan can reliably do this to the "one" side of > the relationship, can it? The documentation seems to imply not:
if you want to delete an object when one of its collections are empty, use events for that. I have an in-depth answer to the "remove an object when all of its many-to-many children are gone" question here: http://stackoverflow.com/questions/9234082/setting-delete-orphan-on-sqlalchemy-relationship-causes-assertionerror-this-att/9264556#9264556 > > |delete-orphan| cascade implies that each child object can only have > one parent at a time, > > > So there isn't an existing mechanism other than session.delete() that I > can see, am I missing something? > > Thanks, Chris. > > -- > You received this message because you are subscribed to the Google > Groups "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
