]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Use pg_index's indnatts when indnkeyatts is not available
authorDenis Laxalde <denis@laxalde.org>
Tue, 20 May 2025 14:26:14 +0000 (10:26 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 20 May 2025 20:00:11 +0000 (22:00 +0200)
commit4c6c1a6e87fe18c7800ecfa042af49da24fac114
tree9b0abe72c19755550f17aff0afffc83447e49aca
parent02fd55490d0627408cb08d2647de1fdcfef0b0d7
Use pg_index's indnatts when indnkeyatts is not available

Using NULL when this column is not available does not work with old PostgreSQL (tested on version 9.6, as reported in #12600).

Instead, use `indnatts` which should be equal to what `indnkeyatts` would be as there is no "included attributes" in the index on these old versions (but only "key columns").

From https://www.postgresql.org/docs/17/catalog-pg-index.html:
* `indnatts`, "The total number of columns in the index [...]; this number includes both key and included attributes"
* `indnkeyatts`, "The number of key columns in the index, not counting any included columns [...]"

Fixes #12600.

Closes: #12611
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12611
Pull-request-sha: 8ff48a6225ec58fdfa84aec75d487238281b1ac1

Change-Id: Idcadcd7db545bc1f73d85b29347c8ba388b1b41d
(cherry picked from commit 9071811de76dea558f932215870e4a5513b30362)
doc/build/changelog/unreleased_20/12600.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/base.py