fix(core): don't double-wrap orderBy in M:N dataloader batch load - #8194
Merged
Conversation
`Collection.init()` merges the target entity's default `orderBy` (and any runtime `orderBy` option) relative to the target entity, but the M:N dataloader batch load fn wrapped it with the collection property name before passing it to `findChildrenFromPivotTable`, which expects it target-relative (the non-dataloader path passes it unwrapped). The pivot query then wrapped it again with the pivot relation name, producing a path like `competency.competencies.name` and failing with 'Trying to order by not existing property'. Closes #8193
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8194 +/- ##
========================================
Coverage 99.65% 99.65%
========================================
Files 287 287
Lines 30386 30386
Branches 8568 8396 -172
========================================
Hits 30282 30282
Misses 100 100
Partials 4 4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Loading an uninitialized M:N collection through the dataloader failed with
Trying to order by not existing propertywhenever anorderBywas in play (target entity defaultorderBy, relationorderBy, or theloadItems()option).Collection.init()merges those intooptions.orderByrelative to the target entity, but the M:N batch load fn wrapped each entry with the collection property name before passing it tofindChildrenFromPivotTable, which expects it target-relative (the non-dataloader path passes it unwrapped).getPivotOrderBythen wrapped it again with the pivot relation name, so the pivot query tried to order by a path likecompetency.competencies.name, which fails the metadata lookup.The fix drops the extra wrapping so the dataloader path matches the non-dataloader one.
Closes #8193