]> 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:40:03 +0000 (13:40 -0400)
commit5b7fc0b2c71a7012130c7850cfba551693bacc98
tree02b1c0fa8d77e2b8153fba6f0c358608db177aaf
parent1e6c3700a3eb8b6944c1da183f113914b23049e6
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
(cherry picked from commit a7275f8e06575dd6edcf84f8083361961e499f92)
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