loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

belongsTo relation lookup fails when fields parameter omits id

Open tdeignan1 opened this issue 3 years ago • 1 comments

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

tdeignan1 avatar Jan 26 '22 06:01 tdeignan1

Thanks for opening an issue, @tdeignan1.

AFAIK, this is expected behaviour. See: https://github.com/loopbackio/loopback-next/issues/6512#issuecomment-707320631

achrinza avatar Jan 28 '22 15:01 achrinza