Re: [sqlalchemy] DELETE CASCADE does not work when foreing key can be nulleable

2017-07-21 Thread Mauro Caceres
Yes, your test is working. In fact Im using pyramid-sqlachemy but the model is defined as show here. I will keep looking to see where is the issue Thanks and I will keep you posted On Friday, July 21, 2017 at 11:16:25 AM UTC-3, Mike Bayer wrote: > > On Fri, Jul 21, 2017 at 7:57 AM, Mauro Caceres

[sqlalchemy] Re: DELETE CASCADE does not work when foreing key can be nulleable

2017-07-21 Thread Seth P
You're naming both tables 'parent_table'. Perhaps that is messing things up? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See

Re: [sqlalchemy] Representing Tree Structures with sqlAlchemy

2017-07-21 Thread Mike Bayer
On Fri, Jul 21, 2017 at 11:40 AM, Nathan Mooth wrote: > So I have a tree-like data structure that I need to store in a way so that I > can see all children or all parents of a query as well as their relative > depth from the query item. In the past I have been using the

[sqlalchemy] Representing Tree Structures with sqlAlchemy

2017-07-21 Thread Nathan Mooth
So I have a tree-like data structure that I need to store in a way so that I can see all children or all parents of a query as well as their relative depth from the query item. In the past I have been using the closure table method demonstrated in this blog post

Re: [sqlalchemy] DELETE CASCADE does not work when foreing key can be nulleable

2017-07-21 Thread Mike Bayer
On Fri, Jul 21, 2017 at 7:57 AM, Mauro Caceres wrote: > Hi Guys, > > Im using sqlachemy SQLAlchemy==1.0.14 on PostgresDB. > > Im trying to understand if it is possible to delete all childs in a one to > many relation but with the distinction that there would be orphans in

[sqlalchemy] DELETE CASCADE does not work when foreing key can be nulleable

2017-07-21 Thread Mauro Caceres
Hi Guys, Im using sqlachemy SQLAlchemy==1.0.14 on PostgresDB. Im trying to understand if it is possible to delete all childs in a one to many relation but with the distinction that there would be orphans in the table, that is childs with the foreign key in NULL. This is what I have Class