loopbackio / loopbackio/loopback-next
belongsTo relation lookup fails when fields parameter omits id
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
Describe the bug
When combining an include parameter with a fields parameter which omits id, the belongsTo relation lookup fails.
Consider the following example, where we find Todo entities with their respective TodoList's titles.
todoRepository.find({include: [{relation: 'todoList', scope: {fields: ['title']}}]});
The returned Todo entities will be missing their respective TodoLists.
Logs
No response
Additional information
No response
Reproduction
https://github.com/tdeignan1/loopback-next/tree/demo/include-with-fields-bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the repository find call shown in the issue and trace how the belongsTo include is resolved when the related scope fields contain only title. Use the linked reproduction to confirm the failure, and consider the work done when the Todo entities include their TodoList despite the omitted id.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100