Skip to content

fix: correct index_attributes for indexes not on leading table columns - #1109

Open
oniani1 wants to merge 1 commit into
supabase:masterfrom
oniani1:fix/indexes-attribute-numbering
Open

fix: correct index_attributes for indexes not on leading table columns#1109
oniani1 wants to merge 1 commit into
supabase:masterfrom
oniani1:fix/indexes-attribute-numbering

Conversation

@oniani1

@oniani1 oniani1 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Closes #1108

The /indexes query joins pg_attribute against the index relation but filters it with a.attnum = ANY(idx.indkey), and indkey holds the table's column numbers, not the index's. That only lines up when the index is on the table's leading columns, so composite indexes lose columns and an index on a later column drops out of the result entirely (and 404s on retrieve-by-id).

Switched the join to a.attnum > 0. The index relation's own attributes are already the index columns in index order, and the existing order by a.attnum keeps them in order, so this returns the full attribute list. It's the same guard columns.sql.ts already uses.

Added a test with a composite index and an index on a non-leading column.

@oniani1
oniani1 requested review from a team, avallete and soedirgo as code owners August 18, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /indexes drops columns and omits indexes not on a table's leading columns

1 participant