]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add scalars method to connection and session classes
authorMiguel Grinberg <miguel.grinberg@gmail.com>
Mon, 13 Sep 2021 18:41:13 +0000 (14:41 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 14 Sep 2021 16:58:37 +0000 (12:58 -0400)
commit4127482cc5edff8967b991bfc9398c47ce6e8a83
tree641293bc096f3b0cae79c77cb8683c19fd94cfb3
parent0277ec7b9d894b16b5ef83ec722c321d5cb3c0e4
Add scalars method to connection and session classes

Added new methods :meth:`_orm.Session.scalars`,
:meth:`_engine.Connection.scalars`, :meth:`_asyncio.AsyncSession.scalars`
and :meth:`_asyncio.AsyncSession.stream_scalars`, which provide a short cut
to the use case of receiving a row-oriented :class:`_result.Result` object
and converting it to a :class:`_result.ScalarResult` object via the
:meth:`_engine.Result.scalars` method, to return a list of values rather
than a list of rows. The new methods are analogous to the long existing
:meth:`_orm.Session.scalar` and :meth:`_engine.Connection.scalar` methods
used to return a single value from the first row only. Pull request
courtesy Miguel Grinberg.

Fixes: #6990
Closes: #6991
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6991
Pull-request-sha: b3e0bb3042c55b0cc5af6a25cb3f31b929f88a47

Change-Id: Ia445775e24ca964b0162c2c8e5ca67dd1e39199f
doc/build/changelog/unreleased_14/6990.rst [new file with mode: 0644]
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/asyncio/session.py
lib/sqlalchemy/orm/session.py
test/engine/test_execute.py
test/ext/asyncio/test_engine_py3k.py
test/ext/asyncio/test_session_py3k.py
test/orm/test_bundle.py
test/orm/test_session.py