如何使用 peewee 在 where 条件之后加入

how to make join after where condition with peewee

是否可以在这样的条件之后进行连接

query = (AppCompany
            .select(AppCompany,User)
            .join(User)
            .where(AppCompany.status_id==request.args.status_id)
        )

if request.args.industry:
    query = query.switch(AppCompany).join(AppCompanyToIndustry)
    query = query.where(AppCompanyToIndustry.industry_id==request.args.industry)

我累了但是它抛出了这个错误:"ValueError: A join condition must be specified."

提供一个加入条件

query = query.switch(AppCompany)
             .join(AppCompanyToIndustry)
             .where(AppCompanyID == AppCompanyToIndustryID)

在这里你应该用适当的列替换 AppCompanyIDAppCompanyToIndustryID