]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
WIP: Retrieve "included" columns in unique/primary key constraint from the index
authorDenis Laxalde <denis@laxalde.org>
Tue, 1 Apr 2025 10:33:43 +0000 (12:33 +0200)
committerDenis Laxalde <denis@laxalde.org>
Tue, 1 Apr 2025 16:55:01 +0000 (18:55 +0200)
commit1aabea7b55ece9fc0c6e069b777d4404ac01f964
treef7ed0c58ee21bb856adde2d4a419f973b4cfb93a
parent1b7a3ba176779dce7afd9b97d680410fae4c1abd
WIP: Retrieve "included" columns in unique/primary key constraint from the index

Replace the previous approach relying on a regex on the result of
pg_get_constraintdef() with a subquery on pg_attribute joined with
pg_index using the 'indkey' column (and excluding 'indnkeyatts').

In tests, in order to make sure the order is okay, we add more columns
to the reflected table and create the constraint with an order different
from table attributes numbering.

TODO:
- test/dialect/postgresql/test_reflection.py::ReflectionTest::test_nullsnotdistinct
  fails, getting an unexpected 'postgresql_include' in 'dialect_options'
- add condition on server_version for the 'include' subquery
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/postgresql/test_reflection.py