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