Skip to content

object.$relatedQuery('relation') builds incorrect query when object's 'join: { from: 'something.id' } has value 0 #228

@minusreality

Description

@minusreality

With a fresh table, user.id is starting with value 0. I ran into this issue with MySQL 5 when using the statement:

user.$relatedQuery('locations').then( ... )

knex debugging yields:
...sql: 'select * from GPSLocation where 1 = ?'

Here is my relationshipMappings:

User.relationMappings = {
  locations: {
    relation: Model.HasManyRelation,
    modelClass: GPSLocation,
    join: {
      from: 'User.id',
      to: 'GPSLocation.user_id'
    }
  }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions