[sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-25 Thread Chris Withers
Hi All, Suppose I have the following: from sqlalchemy import Column, Integer, Text, ForeignKey, and_from sqlalchemy.dialects.postgresql import TSRANGE as Rangefrom sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): id = Column(Integer(), primary_key

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-25 Thread Mike Bayer
On 9/25/15 4:18 AM, Chris Withers wrote: Hi All, Suppose I have the following: from sqlalchemyimport Column, Integer, Text, ForeignKey, and_ from sqlalchemy.dialects.postgresqlimport TSRANGEas Range from sqlalchemy.ext.declarativeimport declarative_base Base = declarative_base() class A(Bas

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-25 Thread Jonathan Vanasco
fwiw, I struggled with this a while back and then gave up. i ended up writing a few filter__xyz() functions that accept/return a query. in the def, I join needed tables and filter. instead of inspecting the query for tables, I just pass in some flags on how to act. It's not pretty, but it wor

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-25 Thread Chris Withers
On 25/09/2015 13:58, Mike Bayer wrote: session.query(A).filter(A.id>10).as_at(now)) you'd need to subclass Query and dig into Query.column_descriptions to get at the existing entities, then add all that criterion. remind me where the docs are for plugging in a subclassed Query into a session?

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-25 Thread Chris Withers
On 25/09/2015 16:35, Jonathan Vanasco wrote: fwiw, I struggled with this a while back and then gave up. i ended up writing a few filter__xyz() functions that accept/return a query. in the def, I join needed tables and filter. instead of inspecting the query for tables, I just pass in some fl

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-25 Thread Jonathan Vanasco
It's a code management style that we ended up on :( -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group,

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-09-26 Thread Mike Bayer
On 9/25/15 12:24 PM, Chris Withers wrote: On 25/09/2015 13:58, Mike Bayer wrote: session.query(A).filter(A.id>10).as_at(now)) you'd need to subclass Query and dig into Query.column_descriptions to get at the existing entities, then add all that criterion. remind me where the docs are for pl

Re: [sqlalchemy] funky session usage to add join conditions and where clauses

2015-10-01 Thread Chris Withers
On 26/09/2015 21:15, Mike Bayer wrote: On 9/25/15 12:24 PM, Chris Withers wrote: On 25/09/2015 13:58, Mike Bayer wrote: session.query(A).filter(A.id>10).as_at(now)) you'd need to subclass Query and dig into Query.column_descriptions to get at the existing entities, then add all that criter