[sqlalchemy] relationship join with same table twice

2014-12-08 Thread Kevin S
I am trying to construct a filter against a table that has two references to the same child table. But I am completely confused how to go about it. I've seen lots of examples for using aliases, but I have not been able to get any to work. So I'll just try to give my example simply, and ask what

Re: [sqlalchemy] history_meta.py IntegrityError: (IntegrityError) duplicate key value violates unique constraint p2docs_history_pkey

2014-12-08 Thread HP3
Thank you all, It turned out that combining SELECT FOR UPDATE and isolation_level SERIALIZABLE and pyramid_tm 0.8 produced the expected result. IOW: everything is now working correctly: The only change to history_meta.py we ended up doing was the following: ``` #attr['version'] =

Re: [sqlalchemy] history_meta.py IntegrityError: (IntegrityError) duplicate key value violates unique constraint p2docs_history_pkey

2014-12-08 Thread HP3
Clarification: Originally, when we tried SELECT FOR UPDATE and isolation_level SERIALIZABLE unsuccessfully, we were using pyramid_tm 0.7. As soon as we upgraded to 0.8, it all started working correctly. On Monday, December 8, 2014 6:15:26 PM UTC-6, HP3 wrote: Thank you all, It turned out

Re: [sqlalchemy] relationship join with same table twice

2014-12-08 Thread Michael Bayer
you’d use aliased and join twice as: c1 = aliased(Child) c2 = aliased(Child) session.query(Parent).join(c1, Parent.child1).outerjoin(c2, Parent.child2).filter(or_(c1.foo == ‘bar’, c2.foo = ‘bar’)) http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#using-aliases