0

This is my model:

class Huse(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    bord = db.Column(db.Text)
    voksne = db.Column(db.Integer)
    born = db.Column(db.Integer)
    auto = db.Column(db.Boolean)

This query gives me the below data:

result = Huse.query.all()

(Formatting left out)

{"199": {"bord": "1", "voksne": 2, "born": 2, "auto": false}, "201": {"bord": "1", "voksne": 2, "born": 2, "auto": true}, "211": {"bord": "1", "voksne": 2, "born": 2, "auto": false}, "217": {"bord": "1", "voksne": 2, "born": 2, "auto": true}}  

But if I do this query:

    result = Huse.query.filter(Huse.auto is True)

I get nothing. Can annyone please explain to me what's wrong?

davidism
  • 121,510
  • 29
  • 395
  • 339
Kresten
  • 810
  • 13
  • 36
  • Does this answer your question? [flake8 complains on boolean comparison "==" in filter clause](https://stackoverflow.com/questions/18998010/flake8-complains-on-boolean-comparison-in-filter-clause) – noslenkwah Apr 27 '20 at 21:03

1 Answers1

0

sqlalchemy doesn't directly support python's "is" syntax. Try replacing is with ==.

AbbeGijly
  • 1,191
  • 1
  • 4
  • 5