Skip to content
This repository was archived by the owner on Apr 17, 2020. It is now read-only.
This repository was archived by the owner on Apr 17, 2020. It is now read-only.

Fix handling of empty rows in (left) joined queries #8

@joelmukuthu

Description

@joelmukuthu

Currently, when a join does not yield any rows, the joined query is added with value null. To remain consistent with the rest of the Query methods, which return an empty array when no rows are returned, this should be fixed such that:

  • if all rows are empty, set the value to []
  • if first is configured, set the value to null

This is a breaking change for all code that checks existence of the joined data:

const foo = await Foo.query.join(Bar, { as: 'bar' }).fetch();
if (foo.bar) { // this will fail
} 

NOTE that this only applies to leftJoin. for join and innerJoin the rows should always be non-empty.

  • ensure that this only applies to leftJoin
  • ensure that for join and innerJoin the rows are always non-empty

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions