Skip to content

Relations are not applied if one of the relation is null #133

@QuentinGab

Description

@QuentinGab

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;
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions