我写了这个循环,使用Sqlalchemy动态构建选择语句,以尽量减少对数据库的访问。但是当调用
代码:
query.all()
时,我不明白为什么会出现“超过最大递归深度”的错误。将递归深度最大值更改为2000后,此查询正常工作。代码:
filter_cond = False
for asset in assets:
filter_cond = or_(filter_cond, and_(model.version == asset.get("version"),
model.id == asset.get("id"),
model.account_id == account_id))
query = session.query(model).filter(filter_cond)
result_set = query.all()
filter_cond = or_((AuthorizationTool.build_statement(model, asset, account_id) for asset in assets))
- RustyShackleford