Relations are not applied if one of the relation is null
QuentinGab opened this issue · comments
Quentin Gabriele commented
Relations are not applied if one of the relation is null.
Exemple:
relations() {
return {
post: Post,
comments: Comment,
};
}
and database response
{
post: null,
comments: [
{title: 'hello world'}
]
}
will not apply the relation on comments.
Maybe _applyRelations
should just ignore null values rather than ending the loop :
_applyRelations(model) {
const relations = model.relations()
for(const relation of Object.keys(relations)) {
const _relation = getProp(model, relation)
if (!_relation) {
return;
}
Peter Krebs commented
@JoaoPedroAS51 Ignoring null values seems to be a better approach. Can you deliver a fix?
João Pedro Antunes Silva commented
Hey! Good catch! Fix is on the way! :)