0
deleted=0
がない場合にのみ、idでユーザを取得したいとします。試しましたクエリをフィルタリングし、SQLAlchemyでidでローを取得する
user = User.query.filter_by(deleted=0).get(id)
エラーが発生しました。どのようにクエリをフィルタリングし、IDで取得するのですか?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/david/.virtualenvs/flask-sqlalchemy/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 831, in get
return self._get_impl(ident, loading.load_on_ident)
File "/home/david/.virtualenvs/flask-sqlalchemy/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 864, in _get_impl
return fallback_fn(self, key)
File "/home/david/.virtualenvs/flask-sqlalchemy/lib/python3.6/site-packages/sqlalchemy/orm/loading.py", line 177, in load_on_ident
q._get_condition()
File "/home/david/.virtualenvs/flask-sqlalchemy/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 350, in _get_condition
"get", order_by=False, distinct=False)
File "/home/david/.virtualenvs/flask-sqlalchemy/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 368, in _no_criterion_condition
self._no_criterion_assertion(meth, order_by, distinct)
File "/home/david/.virtualenvs/flask-sqlalchemy/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 365, in _no_criterion_assertion
"Query with existing criterion. " % meth)
sqlalchemy.exc.InvalidRequestError: Query.get() being called on a Query with existing criterion.