Problem when querying the database
When I do:
channel = session.query(Channel).options(eagerload("items")).filter(Channel.title == title)
I get this error:
TypeError: 'bool' object is not callable
If I rid of options(eagerload("items"))
, it's working properl开发者_JS百科y.
Any idea??
Thanks in advance!
SQLAlchemy filtering works with operator overloading on column objects. You are, however, not referencing the column object, but the value property of the table. So instead of
Channel.title == title
which is a 'bool' object, you need
Channel.c.title == title
which yields a SLQAlchemy specific object.
精彩评论