flask-sqlalchemy icon indicating copy to clipboard operation
flask-sqlalchemy copied to clipboard

Rename `first_or_404` and `one_or_404` to `scalar_or_404` and `scalar_one_or_404`

Open greyli opened this issue 1 year ago • 0 comments

The underly implementation of first_or_404 and one_or_404 is use scalar() and scalar_one(). I think it will be more clear to rename them to scalar_or_404 and scalar_one_or_404, so users won't expect or worry first_or_404 and one_or_404 will return a Row object/tuple.

It seems reasonable to change the old names to match the new behaviors of SQLAlchemy 2.x style. The old names can be kept for backward compatibility.

I will add the tests, and update the docs if this change will be accepted.

Checklist:

  • [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • [ ] Add or update relevant docs, in the docs folder and in code.
  • [ ] Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • [x] Add .. versionchanged:: entries in any relevant code docs.
  • [x] Run pre-commit hooks and fix any issues.
  • [x] Run pytest and tox, no tests failed.

greyli avatar Feb 26 '23 14:02 greyli