loopback-next
loopback-next copied to clipboard
belongsTo relation lookup fails when fields parameter omits id
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
Thanks for opening an issue, @tdeignan1.
AFAIK, this is expected behaviour. See: https://github.com/loopbackio/loopback-next/issues/6512#issuecomment-707320631