Hi All,
This might be a noob question, but I wasn't able to to find the answer
combing through the docs and google search. Given the following
declarations
Base = declarative_base()
class A(Base):
__tablename__ = 'A'
id = Column(Integer, primary_key=True)
class B(Base):
__tablename__ = 'B'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey('A.id'))
a = relationship('A', backref=backref('b'))
I want to query for all A where B is not null (essentially an inner
join on A) with something like this
session.query(A).options(joinedload('b')).filter(A.b != None)
but it won't work because 'A.b' is a backref field. If I try
filter('A.b' != None) it won't work either. So 2 part question:
1) is there a better way to do an inner join like this?
2) in general, how do you use backref fields inside of filter
criteria?
Thanks,
Alan
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.