From fcc704f0909ca21cd998bd0fc3896d02aa0fe2fd Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Mon, 27 Jul 2026 00:53:13 +0800 Subject: [PATCH] docs: document sequence arguments to any_ and all_ --- lib/sqlalchemy/sql/_elements_constructors.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/sqlalchemy/sql/_elements_constructors.py b/lib/sqlalchemy/sql/_elements_constructors.py index 1273d7c23a..7da1107d55 100644 --- a/lib/sqlalchemy/sql/_elements_constructors.py +++ b/lib/sqlalchemy/sql/_elements_constructors.py @@ -84,6 +84,12 @@ def all_(expr: _ColumnExpressionArgument[_T]) -> CollectionAggregate[bool]: # '5 = ALL (SELECT value FROM table)' expr = 5 == all_(select(table.c.value)) + When using a Python sequence with PostgreSQL, wrap it with + :func:`_sql.literal` to produce a SQL expression. Whether the sequence + can be adapted to an array parameter is DBAPI-specific:: + + expr = 5 == all_(literal([1, 2, 3])) + Comparison to NULL may work using ``None``:: None == all_(mytable.c.somearray) @@ -267,6 +273,12 @@ def any_(expr: _ColumnExpressionArgument[_T]) -> CollectionAggregate[bool]: # '5 = ANY (SELECT value FROM table)' expr = 5 == any_(select(table.c.value)) + When using a Python sequence with PostgreSQL, wrap it with + :func:`_sql.literal` to produce a SQL expression. Whether the sequence + can be adapted to an array parameter is DBAPI-specific:: + + expr = 5 == any_(literal([1, 2, 3])) + Comparison to NULL may work using ``None`` or :func:`_sql.null`:: None == any_(mytable.c.somearray) -- 2.47.3