]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Cast empty PostgreSQL ARRAY from the type specified to array() 12435/head
authorDenis Laxalde <denis@laxalde.org>
Fri, 14 Mar 2025 11:02:20 +0000 (12:02 +0100)
committerDenis Laxalde <denis@laxalde.org>
Wed, 19 Mar 2025 07:18:32 +0000 (08:18 +0100)
commit9633d3c15d42026f8f45f5a4d201a5d72e57b8d4
tree9d5d1e0ebd6da8e497141ec57c5ae70e342b1812
parentae221534846eb095e50fce99d641f794916bf917
Cast empty PostgreSQL ARRAY from the type specified to array()

When using `postgresql.array()` with an empty list as `clauses` and a
`type_` argument specified, we now cast the resulting `ARRAY[]` SQL
expression using that type information thus removing the need for an
explicit cast on user side.

We need to add the 'type' attribute to the cache key of
`postgresql.array` in order to distinguish statements produced with an
empty list clause and with or without a `type_` argument.
doc/build/changelog/unreleased_20/12432.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/array.py
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/postgresql/test_compiler.py
test/dialect/postgresql/test_query.py
test/sql/test_compare.py