0

假设我有一个查询对象

query = session.query(SomeModel) \
    .filter(SomeModel.foo == 'bar') \
    .filter(SomeModel.active == True)

您能否在执行查询之前修改对象列表,保持所有相同的过滤器

IE

.change_query(SomeModel.id, SomeModel.name)

这样生成的查询对象是:

session.query(SomeModel.id, SomeModel.name) \
    .filter(SomeModel.foo == 'bar') \
    .filter(SomeModel.active == True)
4

1 回答 1

0

哇已经找到答案了。如果人们正在搜索这个,将保持打开状态:

query = query.with_entities(SomeModel.id, SomeModel.name)
于 2012-07-16T22:58:00.963 回答