说我有一个查询对象
query = session.query(SomeModel) \
.filter(SomeModel.foo == 'bar') \
.filter(SomeModel.active == True)
可以在执行查询之前修改对象列表,维护所有相同的过滤器
即
.change_query(SomeModel.id, SomeModel.name)
以便生成的查询对象为:
session.query(SomeModel.id, SomeModel.name) \
.filter(SomeModel.foo == 'bar') \
.filter(SomeModel.active == True)
答案 0 :(得分:0)
query = query.with_entities(SomeModel.id, SomeModel.name)