Hi,
I have to perform a query who filter in the last relations created an
attribute, but I don't know how to do. I checked the doc and I don't get it
class Statustype(Base):
__tablename__ = 'statustypes'
id = Column(Integer, nullable=False, primary_key=True)
naam = Column(String(50), nullable=False)
class Status(Base):
__tablename__ = 'statussen'
id = Column(Integer, nullable=False, primary_key=True)
statustype_id = Column(Integer, ForeignKey('statustypes.id'),
nullable=False)
datum = Column(DateTime(timezone=True), nullable=False,
default=func.now())
status = relationship('Statustype')
class Object(Base):
__tablename__ = 'aanduidingsobjecten'
naam = Column(String(255), nullable=False)
type_id = Column(Integer, ForeignKey('aanduidingsobjecttypes.id'),
nullable=False)
statussen = relationship(
"AanduidingsobjectStatus",
order_by='desc(AanduidingsobjectStatus.status_datum)',
backref='aanduidingsobject',
cascade='all, delete, delete-orphan',
lazy='subquery'
)
here is the query I got so far :
session.query(Object)\
.join(Object.statussen)\
.filter(Statustype.id > 50).all()
But I don't see how to perform the check on the last status and all in only
one query. Do you have an idea?
--
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 http://stackoverflow.com/help/mcve for a full description.
---
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 https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/99bc3fc7-d2fb-4629-b81e-b1558e578669%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.