Re: [sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-16 Thread Jay Pipes
On Sun, 2014-02-16 at 12:17 -0500, Michael Bayer wrote: > > On Feb 15, 2014, at 11:38 PM, Jay Pipes wrote: > > > Thank you Michael. Yes, that is indeed the case if I delete an > > object via session.delete(). > > > > Unfortunately, it seems that if I execute the DELETE manually > > against the

Re: [sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-16 Thread Michael Bayer
On Feb 15, 2014, at 11:38 PM, Jay Pipes wrote: > Thank you Michael. Yes, that is indeed the case if I delete an object via > session.delete(). > > Unfortunately, it seems that if I execute the DELETE manually against the > table in question, that the delete does not cascade, as shown by this

Re: [sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-15 Thread Jay Pipes
Thank you Michael. Yes, that is indeed the case if I delete an object via session.delete(). Unfortunately, it seems that if I execute the DELETE manually against the table in question, that the delete does not cascade, as shown by this code: http://paste.openstack.org/show/66005/ Does this mea

Re: [sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-09 Thread Michael Bayer
the problem is this: org = Organization(name='my org') sess.add(org) group = Group(name='my group') group.organization_id = org.id sess.add(group) when you assign group.organization_id = org.id, org has not been flushed yet so org.id is None. The org is then never associate

[sqlalchemy] Many to many association record orphaned when deleting parent of parent of relation

2014-02-09 Thread Jay Pipes
Hi all, I have some models with the following relationship: An Organization can have many Groups A Group belongs to one Organization A User can belong to many Groups A Group can have many Users I use a mapping model called UserGroupMembership that stores the user_id, group_id relation of the ma