Skip to content

Commit

Permalink
added test which fails without the fix
Browse files Browse the repository at this point in the history
with error: `no such column: model2.model2_prop2`
  • Loading branch information
falkenhawk authored and lehni committed May 17, 2023
1 parent f791822 commit af48971
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/integration/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,27 @@ module.exports = (session) => {
});
});

it('.where() with a subquery and aliases (using tableRefFor in subquery)', () => {
return Model2.query()
.alias('m1')
.where((query) =>
query.where(
'id_col',
Model2.query()
.select('m2.id_col')
.alias('m2')
.where(
'm2.model2_prop2',
ref(`${query.tableRefFor(query.modelClass())}.model2_prop2`)
)
)
)
.orderBy('m1.model2_prop2')
.then((models) => {
expect(_.map(models, 'model2Prop2').sort()).to.eql([10, 20, 30]);
});
});

it('.where() with an object and knex query builder', () => {
return Model2.query()
.where({
Expand Down

0 comments on commit af48971

Please sign in to comment.