]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
We can't promise CursorResult from session.execute()
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Aug 2025 15:01:47 +0000 (11:01 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Aug 2025 17:34:49 +0000 (13:34 -0400)
commit67f62aac5b49b6d048ca39019e5bd123d3c9cfb2
tree60522ce47c942435101bf12d13c9d3121a66feeb
parentde89d598744edc9365279a682a95e198dfbf1f29
We can't promise CursorResult from session.execute()

Fixed typing bug where the :meth:`.Session.execute` method advertised that
it would return a :class:`.CursorResult` if given an insert/update/delete
statement.  This is not the general case as several flavors of ORM
insert/update do not actually yield a :class:`.CursorResult` which cannot
be differentiated at the typing overload level, so the method now yields
:class:`.Result` in all cases.  For those cases where
:class:`.CursorResult` is known to be returned and the ``.rowcount``
attribute is required, please use ``typing.cast()``.

Fixes: #12813
Change-Id: I8a7197100db312b3898c66ceddd6638e68c6bb44
doc/build/changelog/unreleased_20/12813.rst [new file with mode: 0644]
lib/sqlalchemy/ext/asyncio/scoping.py
lib/sqlalchemy/ext/asyncio/session.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/scoping.py
lib/sqlalchemy/orm/session.py
test/typing/plain_files/orm/typed_queries.py