Skip to content

Extend tiebreaking to all association orderings#3006

Open
goosys wants to merge 1 commit intothoughtbot:mainfrom
goosys:fix/stableoder
Open

Extend tiebreaking to all association orderings#3006
goosys wants to merge 1 commit intothoughtbot:mainfrom
goosys:fix/stableoder

Conversation

@goosys
Copy link
Copy Markdown
Contributor

@goosys goosys commented Mar 19, 2026

Previously, tiebreaking by primary key was introduced for direct column ordering.
However, association-based orderings (has_many, belongs_to, has_one) did not benefit from the same behavior.

This PR extends tiebreaking to all association orderings by extracting the logic into a shared with_tiebreak helper. Each association ordering method now passes its result through with_tiebreak, which appends an ORDER BY primary_key clause when applicable.

No tiebreak is added when the parent relation has no primary key.

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.

1 participant