So I'm creating a query with sqlalchemy and I don't know why i get this error. Basicaly my code looks like this : def post(self, semestr): nazwa_kierunku = 'stac. I st., kier. informatyka' nr_semestru = 2 nr_grupy_cw = 3 nr_grupy_ps = 5 nr_grupy_l = 7 nr_grupy_w = 1 nr_grupy_p = 2 nr_grupy_s = 5 nr_grupy_j = 5 nr_grupy_wf = 1 prowadzacy_tytul_subq = model.Prowadzacy.query.join(model.Tytul).subquery() query = ( model.Grupa.query.join(prowadzacy_tytul_subq, model.Studia, model.Przedmiot, model.Sala) .filter(model.Studia.nazwa == nazwa_kierunku) .filter(model.Grupa.nr_semestru == nr_semestru) .filter((model.Grupa.rodzaj == 'Ćw', model.Grupa.nr_grupy == nr_grupy_cw) | (model.Grupa.rodzaj == 'Ps' , model.Grupa.nr_grupy == nr_grupy_ps)) ) print(query) result = schema.GrupaSchema().dump(query, many=True) return jsonify(result) When I mouse over the '|' operator i get "Class'(bool,bool)' does not define 'or', so the '|' operator cannot be used on its instances" During compilation I get "sqlalchemy.exc.ArgumentError: SQL expression object or string expected, got object of type instead" What I'm doing wrong? Continue reading...