问题描述
我根据需要使用了表之间的连接。在循环中,我需要检查条件的相关性,并在执行时将查询添加到最终选择中。请告诉我如何将符合条件的当前查询添加到“答案”选择中?
这是我的代码:
def resolve_doops(self,info):
answer=[]
query = db.query(DOOP,Direction,Category,Category_DOOP)
query = query.join(Direction,Direction.id_cluster == DOOP.id_cluster)
query = query.join(Category_DOOP,Category_DOOP.id_doop == DOOP.id)
query = query.join(Category,Category_DOOP.id_category == Category.id)
query = query.all()
for doop,diretion,category_doop,category in query:
if (doop.ovz == bool(self.ovz)):
answer.append(????)
return answer
def resolve_doops(self,info):
query = db.query(DOOP,Category_DOOP)
query = query.filter_by(ovz=self.ovz)
query = query.join(Direction,Direction.id_cluster == DOOP.id_cluster)
query = query.filter(Direction.name.in_(self.direction))
query = query.join(Category_DOOP,Category_DOOP.id_category == Category.id)
query = query.filter(Category.age_max.in_(self.age),Category.age_min.in_(self.age))
query = query.all()
return query
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)