mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
c427615234
## TL;DR Correctly pairs composite foreign key columns when loading table metadata. ## What's hurting? The tables introspection query matched every source column in a composite foreign key with every target column. For `(user_id, tenant_id) → (id, tenant_id)`, it returned four relationships instead of the correct two, causing incorrect relationship metadata in the Table Editor... ## Now fixed Source and target columns are paired by ordinal position using a lateral multi-array `unnest`. Regression coverage now verifies adversarial column ordering, and the existing performance guard exercises thousands of composite foreign keys... PS: local stress test found no performance regression or unexpected sequential scans. ## Ref - Closes #41068 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected foreign-key relationship detection for composite keys, ensuring source and target columns are paired accurately. * Improved catalog relationship queries to remain within performance limits for composite-key tables. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>