Search code examples
knex.jsobjection.js

objectionjs column reference is ambiguous


I try to make a query with a join relation with objection.js.

Here is the datastructure:

enter image description here

Here is the query:

Titres.query()
      .skipUndefined()
      .whereIn('typeId', typeIds)
      .whereIn('domaineId', domaineIds)
      .whereIn('statutId', statutIds)
      .joinRelation('demarches.etapes.substances')
      .where('demarches:etapes:substances.id', substances)
      .eager('[domaine, demarches.[type, etapes.substances.domaine]]')

This makes an error: column reference \"domaine_id\" is ambiguous

How is it possible to make it work?


Solution

  • prefix the conflicting table: whereIn('titres.domaineId'