开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜