Skip to content

Sort reverse-engineered foreign keys by name - #156

Merged
chulanovskyi-bs merged 2 commits into
developfrom
fix/bigquery-re-foreign-keys-order
Nov 10, 2026
Merged

chulanovskyi-bs merged 2 commits into
developfrom
fix/bigquery-re-foreign-keys-order

Conversation

@bigorn0

@bigorn0 bigorn0 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Content

Reverse-engineering now returns foreign keys sorted by name, so their order is the same on every run.

Before, the order followed the rows of the foreign key query, which has no ORDER BY. BigQuery doesn't keep row order stable, so the Studio BigQuery feature test sometimes failed with simpleFK and fk$1 swapped (TeamCity build 326579).

Technical details

  • The fix is one line in reverseForeignKeys: the list of constraint names is sorted. Columns inside each key were already sorted by ordinal_position.
  • Running the query 80 times against the test project returned the same rows every time, in a different order 5 times.
  • Must be merged together with https://github.com/hackolade/studio/pull/6792, which updates expectedRE.json (same branch name, so TeamCity builds them together). Merged alone, either one makes the Studio test fail.

bigorn0 and others added 2 commits November 10, 2026 12:13
The foreign key query has no ORDER BY, so BigQuery returns rows in a
different order from run to run, and the relationships came out in a
different order too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@chulanovskyi-bs
chulanovskyi-bs merged commit 2e084b6 into develop Nov 10, 2026
1 check passed
@chulanovskyi-bs
chulanovskyi-bs deleted the fix/bigquery-re-foreign-keys-order branch November 10, 2026 11:25
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.

2 participants