]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Block Result.unique() with Result.yield_per() for ORM results
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 May 2026 18:30:37 +0000 (14:30 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 May 2026 22:47:56 +0000 (18:47 -0400)
commit15a9df9b2db9603ecaa8635396596b4ecca7d481
treef9d463afb1fc23644a9331c09a41bda40375802b
parent1e1c0084b1804eaae8b7f089435241a2b8f4be60
Block Result.unique() with Result.yield_per() for ORM results

The unique() + yield_per combination was only blocked when yield_per
was set via execution_options(yield_per=N); calling these as methods
on the result (e.g. result.unique().yield_per(N)) bypassed the check
and silently produced incorrect results.

Restructured _unique_filters on SimpleResultMetaData to be a callable
_create_unique_filters that receives the Result, allowing it to check
the yield_per state regardless of how it was activated.

Fixes: #13293
Change-Id: I7e6a5e5b2e1d4c8f9a0b3d6e7f1c2a4d5b8e9f0a
doc/build/changelog/unreleased_21/13293.rst [new file with mode: 0644]
lib/sqlalchemy/engine/_result_cy.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/orm/loading.py
test/aaa_profiling/test_memusage.py
test/base/test_result.py
test/orm/test_query.py