开发者

Problem when querying the database

开发者 https://www.devze.com 2023-01-25 19:41 出处:网络
When I do: channel = session.query(Channel).options(eagerload(\"items\")).filter(Channel.title == title)

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消