问题
Postgres model:
class Song(db.Model):
id3_parsed = db.Column(db.Boolean, server_default=u'false')
Running the following query gives the correct count:
select count(*) from song where id3_parsed is false;
But how do I do it with flask-sqlalchemy? This doesn't work:
songs = Song.query.filter(Song.id3_parsed == False).all()
回答1:
songs = Song.query.filter(Song.id3_parsed.is_(False)).all()
来源:https://stackoverflow.com/questions/31811119/boolean-field-query-with-sqlalchemy