]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
dont render VARCHAR length for PG casts
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 19 Mar 2023 14:37:15 +0000 (10:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 19 Mar 2023 17:33:23 +0000 (13:33 -0400)
commitfa0666cb04174cdd2592ab1327d48e431fe86ffa
tree020edb674c435b2b3a3ba4e3a4fbdb4556ab93a2
parentb56494ba64f858a60a3314fd549ced4512a5fe19
dont render VARCHAR length for PG casts

Fixed critical regression in PostgreSQL dialects such as asyncpg which rely
upon explicit casts in SQL in order for datatypes to be passed to the
driver correctly, where a :class:`.String` datatype would be cast along
with the exact column length being compared, leading to implicit truncation
when comparing a ``VARCHAR`` of a smaller length to a string of greater
length regardless of operator in use (e.g. LIKE, MATCH, etc.). The
PostgreSQL dialect now omits the length from ``VARCHAR`` when rendering
these casts.

Fixes: #9511
Change-Id: If094146d8cfd989a0b780872f38e86fd41ebfec2
doc/build/changelog/unreleased_20/9511.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/testing/suite/test_types.py
test/dialect/postgresql/test_query.py
test/dialect/postgresql/test_types.py
test/sql/test_type_expressions.py