]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
CAST the elements in ARRAYs when using psycopg2
authorFederico Caselli <cfederico87@gmail.com>
Wed, 10 Mar 2021 22:54:52 +0000 (23:54 +0100)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Mar 2021 19:26:03 +0000 (15:26 -0400)
commit65da8070e273ee2ea8ea71ba208d8645633b3fa0
tree4a7290b6bf2765f994a5297473734d7d52bca050
parent86e3bc144caf8a8bbfe304f665af15daf0bc53c6
CAST the elements in ARRAYs when using psycopg2

Adjusted the psycopg2 dialect to emit an explicit PostgreSQL-style cast for
bound parameters that contain ARRAY elements. This allows the full range of
datatypes to function correctly within arrays. The asyncpg dialect already
generated these internal casts in the final statement. This also includes
support for array slice updates as well as the PostgreSQL-specific
:meth:`_postgresql.ARRAY.contains` method.

Fixes: #6023
Change-Id: Ia7519ac4371a635f05ac69a3a4d0f4e6d2f04cad
(cherry picked from commit dfa1d3b28f1a0abf1e11c76a94f7a65bf98d29af)
12 files changed:
doc/build/changelog/unreleased_13/6023.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/array.py
lib/sqlalchemy/dialects/postgresql/psycopg2.py
lib/sqlalchemy/sql/crud.py
lib/sqlalchemy/sql/sqltypes.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/testing/config.py
lib/sqlalchemy/testing/plugin/pytestplugin.py
lib/sqlalchemy/testing/schema.py
test/dialect/postgresql/test_compiler.py
test/dialect/postgresql/test_types.py
test/sql/test_types.py