]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
support bind expressions w/ expanding IN; apply to psycopg2
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 13 Oct 2021 19:52:12 +0000 (15:52 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Oct 2021 13:28:49 +0000 (09:28 -0400)
commit639cf972f15c8fbf77980b04fff8e5dbc82af7b6
tree162aafe94f82df3e34675ba26b5c88ce4f1b2044
parentfec2b6560c14bb28ee7fc9d21028844acf700b04
support bind expressions w/ expanding IN; apply to psycopg2

Fixed issue where "expanding IN" would fail to function correctly with
datatypes that use the :meth:`_types.TypeEngine.bind_expression` method,
where the method would need to be applied to each element of the
IN expression rather than the overall IN expression itself.

Fixed issue where IN expressions against a series of array elements, as can
be done with PostgreSQL, would fail to function correctly due to multiple
issues within the "expanding IN" feature of SQLAlchemy Core that was
standardized in version 1.4.  The psycopg2 dialect now makes use of the
:meth:`_types.TypeEngine.bind_expression` method with :class:`_types.ARRAY`
to portably apply the correct casts to elements.  The asyncpg dialect was
not affected by this issue as it applies bind-level casts at the driver
level rather than at the compiler level.

as part of this commit the "bind translate" feature has been
simplified and also applies to the names in the POSTCOMPILE tag to
accommodate for brackets.

Fixes: #7177
Change-Id: I08c703adb0a9bd6f5aeee5de3ff6f03cccdccdc5
doc/build/changelog/unreleased_14/7177.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/dialects/postgresql/psycopg2.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/sql/compiler.py
test/dialect/postgresql/test_types.py
test/sql/test_external_traversal.py
test/sql/test_type_expressions.py