2
我试图让下面的查询:AttributeError的:“布尔”对象在Peewee没有属性“克隆”的SQLite
ignored = Activity.select().join(StuActIgnore).join(Student).where(Student.id == current_user.id)
Activity.select().where(~(Activity.name**"%BBP") & Activity not in ignored)
这不会给我任何错误,但以下任何一项:
Activity.get(~(Activity.name**"%BBP") & Activity not in ignored)
Activity.select().where(~(Activity.name**"%BBP") & Activity not in ignored).join(Course)
给了我以下错误:
AttributeError: 'bool' object has no attribute 'clone'
如果我试试这个:
Activity.select().join(Course).join(StuCouRel).join(Student).where(~(Activity.name**"%BBP") & Activity not in ignored & Student.id == current_user.id)
它会告诉我说:
TypeError: argument of type 'Expression' is not iterable
我觉得这是非常令人困惑,因为这个:
already_selected = Course.select().join(StuCouRel).join(Student).where(Student.id == current_user.id)
to_choose = Course.select().where(Course not in already_selected)
工作完全正常,而这是非常类似于我想要看来。
我完全不知道这可能意味着什么,我在文档中找不到任何东西。 'bool'对象可能代表布尔值,但我看不到我的查询结果是一个布尔值。我也不知道'克隆'是什么意思,我也不知道如何解决这个错误。
也有一个疑难杂症我倾向于现在,然后打每一个;忘记在等价性检查中提供模型属性..即做Account.get(name == name)而不是Account.get(Account.name == name)。 第一段代码结束查询“..FROM”帐户“AS t1 WHERE?[True]”,并且在此处失败https://github.com/coleifer/peewee/blob/2.6.1/peewee.py #L2252与 “AttributeError:'bool'对象没有属性'clone'” 它会很好,如果它会在提醒语法中包装异常。 :) – stt
@stt照顾做出答案? – grandchild