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(Base):
     id = Column(Integer(),primary_key=True)
     period = Column(Range(),nullable=False,primary_key=True)
     data = Column(Text())

class B(Base):
     id = Column(Integer(),primary_key=True)
     period = Column(Range(),nullable=False,primary_key=True)
     data = Column(Text())
     a_id =  Column('a_id', Integer(), ForeignKey('a.id'))

     data = Column(Text())

class C(Base):
     id = Column(Integer(),primary_key=True)
     period = Column(Range(),nullable=False,primary_key=True)
     data = Column(Text())
     b_id =  Column('b_id', Integer(), ForeignKey('b.id'))
How would I write something that molested the session such that instead of writing:

session.query(A, B, C)
        .select_from(A).join(B, and_(A.id==B.a_id,
                                     A.period.contains(now),
                                     B.period.contains(now)).
                       .join(C, and_(B.id==C.b_id,
                                     C.period.contains(now)))
...I could write:

session.query(A, B, C).as_at(now)
And instead of writing:

session.query(A).filter(A.id>10).filter(A.period.contains(now))
I could write:

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.


Lazily yours,

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.

Reply via email to