]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Register func.any(), func.all(), func.some() as collection aggregates
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 4 Jun 2026 14:17:06 +0000 (10:17 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 4 Jun 2026 14:25:33 +0000 (10:25 -0400)
commitb14415fa43dd676dd215fec0c18e756db43a70ff
tree9c3b348044594faed195b5c8f2607da0340b1561
parentabfe6cc47c12b87164a63739e3718257b452dac6
Register func.any(), func.all(), func.some() as collection aggregates

Added CollectionAggregateFunction base class that sets
_is_collection_aggregate = True, and registered any_, all_, some_
as subclasses so that func.any(), func.all(), and func.some() correctly
prevent operator flipping on negation. Previously ~(col == func.any(arr))
would incorrectly compile to col != any(arr) instead of
NOT (col = any(arr)), which has different semantics for collection
aggregate comparison modifiers.

Also extended the _construct_for_op guard to check both left and right
operands for _is_collection_aggregate, since func.any(arr) can appear
on either side of a comparison unlike the standalone any_() construct
which auto-reverses operands.

Fixes: #13343
Change-Id: Id4774938876dc7f1f38cf143dccfe3c8ddba464d
doc/build/changelog/unreleased_21/13343.rst [new file with mode: 0644]
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/functions.py
test/sql/test_functions.py