We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On this page https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/queries/#select, the information for querying one object is slightly incorrect.
user = db.session.execute(db.select(User).filter_by(username=username)).one()
This yields something like:
(<User 1>,)
I believe this is because we are working with the ORM models, so we need to use ScalarResult instead of Result. See https://docs.sqlalchemy.org/en/14/core/connections.html#sqlalchemy.engine.ScalarResult
So I think the example should read:
user = db.session.execute(db.select(User).filter_by(username=username)).scalars().one()
This will yield the model with out the tuple.
<User 1>
Environment:
I'm happy to update the documentation. I was considering sending a pull request, but it's late, so ended up filing a bug instead.
The text was updated successfully, but these errors were encountered:
b48c2da
Sorry, something went wrong.
No branches or pull requests
On this page https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/queries/#select, the information for querying one object is slightly incorrect.
This yields something like:
I believe this is because we are working with the ORM models, so we need to use ScalarResult instead of Result. See https://docs.sqlalchemy.org/en/14/core/connections.html#sqlalchemy.engine.ScalarResult
So I think the example should read:
This will yield the model with out the tuple.
Environment:
I'm happy to update the documentation. I was considering sending a pull request, but it's late, so ended up filing a bug instead.
The text was updated successfully, but these errors were encountered: