fix: scope orderable join reordering by parent relation#15842
Merged
GermanJablo merged 7 commits intopayloadcms:mainfrom Mar 6, 2026
Merged
fix: scope orderable join reordering by parent relation#15842GermanJablo merged 7 commits intopayloadcms:mainfrom
GermanJablo merged 7 commits intopayloadcms:mainfrom
Conversation
Prevent unrelated join records from influencing fractional index generation by applying the join `on` field as a scope in both default key assignment and reorder adjacency lookup. Add a regression test covering cross-parent interference for orderable join fields.
Split the orderable setup and reorder endpoint internals into focused utility functions with TSDoc so index orchestration stays minimal and easier to review, while preserving join-scope ordering behavior.
Move untouched orderable helpers back into index so the utils folder only contains logic introduced for the join-scope behavior in this PR.
Move scoped-join reorder helpers into focused utils so index.ts only keeps orchestration, making the functional root-cause changes easier to review.
Replace the orderable-specific where wrapper with Payload's shared combineWhereConstraints helper and remove the redundant local utility.
Allow orderable join scope resolution to fetch the target doc when IDs are numeric, which is required by sqlite/postgres adapters. Without this, scope detection is skipped and key generation can regress to global ordering.
DanRibbens
requested changes
Mar 4, 2026
Contributor
DanRibbens
left a comment
There was a problem hiding this comment.
Looks great, one question came up though.
Added `req` parameter to `getJoinScopeContext` and `resolvePendingTargetKey` functions to support localized join reordering. Introduced a new test case to validate the behavior of localized join reorder keys based on request locale context. Updated the orderable field configuration to be localized, ensuring proper handling of localized data during reordering operations.
DanRibbens
approved these changes
Mar 6, 2026
Contributor
|
🚀 This is included in version v3.79.1 |
|
How can this be used in a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The root problem was scope leakage in join-based ordering. Reorder operations were effectively treating join items as one shared list, so moving an item in one parent context could influence ordering in a different parent context.
Changes
onscope as the target item.pendingnow resolve against scoped context before computing new keys.index.tskeeps orchestration, and scoped query logic is extracted into focused helpers to keep behavior changes easier to review.combineWhereConstraintsutility.Impact
Users can reorder join rows without cross-parent side effects. Items in unrelated parent relations no longer jump or get new keys from another parent's ordering context.