8000
Skip to content

fix(core): don't double-wrap orderBy in M:N dataloader batch load - #8194

Merged
B4nan merged 1 commit into
masterfrom
claude/issue-8193-f5afee
Aug 21, 2026
Merged

fix(core): don't double-wrap orderBy in M:N dataloader batch load#8194
B4nan merged 1 commit into
masterfrom
claude/issue-8193-f5afee

Conversation

@B4nan
@B4nan B4nan commented Aug 21, 2026
Copy link
Copy Markdown
Member

Loading an uninitialized M:N collection through the dataloader failed with Trying to order by not existing property whenever an orderBy was in play (target entity default orderBy, relation orderBy, or the loadItems() option).

Collection.init() merges those into options.orderBy relative to the target entity, but the M:N batch load fn wrapped each entry with the collection property name before passing it to findChildrenFromPivotTable, which expects it target-relative (the non-dataloader path passes it unwrapped). getPivotOrderBy then wrapped it again with the pivot relation name, so the pivot query tried to order by a path like competency.competencies.name, which fails the metadata lookup.

The fix drops the extra wrapping so the dataloader path matches the non-dataloader one.

Closes #8193

`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
codecov Bot commented Aug 21, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.65%. Comparing base (3bc4ba7) to head (bbd1ac6).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@B4nan
B4nan merged commit 20aa5a8 into master Aug 21, 2026
26 checks passed
@B4nan
B4nan deleted the claude/issue-8193-f5afee branch August 21, 2026 14:52
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.

M:N Collection.loadItems() with DataLoader double-wraps target entity default orderBy

1 participant

0