]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Establish deprecation path for CursorResult.keys()
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 May 2021 17:31:51 +0000 (13:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 May 2021 17:49:43 +0000 (13:49 -0400)
commitd6ec248fa7083fee93b669ab27474f6c8f69944d
tree6f244ef0bde129a4519ca4439e25d8150a58b2b3
parentf1f4f466fd809a14bff6d0c405a1d5da87438379
Establish deprecation path for CursorResult.keys()

Established a deprecation path for calling upon the
:meth:`_cursor.CursorResult.keys` method for a statement that returns no
rows to provide support for legacy patterns used by the "records" package
as well as any other non-migrated applications. Previously, this would
raise :class:`.ResourceClosedException` unconditionally in the same way as
it does when attempting to fetch rows. While this is the correct behavior
going forward, the :class:`_cursor.LegacyCursorResult` object will now in
this case return an empty list for ``.keys()`` as it did in 1.3, while also
emitting a 2.0 deprecation warning. The :class:`_cursor.CursorResult`, used
when using a 2.0-style "future" engine, will continue to raise as it does
now.

Fixes: #6427
Change-Id: I4148f28c88039e4141deeab28b1a5994e6d6e098
doc/build/changelog/unreleased_14/6427.rst [new file with mode: 0644]
lib/sqlalchemy/engine/cursor.py
test/sql/test_deprecations.py
test/sql/test_resultset.py