]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Use pg_index's indnatts when indnkeyatts is not available 12611/head
authorDenis Laxalde <denis@laxalde.org>
Tue, 20 May 2025 13:55:44 +0000 (15:55 +0200)
committerDenis Laxalde <denis@laxalde.org>
Tue, 20 May 2025 14:16:09 +0000 (16:16 +0200)
commit8ff48a6225ec58fdfa84aec75d487238281b1ac1
treee6aa7fea3b7650757f21f7355a7bb9e87ad204e5
parent5e9be1867c0259811cc9518f3cad079e30e6e466
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.
doc/build/changelog/unreleased_20/12600.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/base.py