Skip to content

Commit

Permalink
test: add integration tests for #3485
Browse files Browse the repository at this point in the history
  • Loading branch information
edvardchen committed Oct 28, 2019
1 parent ef124fa commit 1e996f7
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/integration/builder/selects.js
Expand Up @@ -1380,5 +1380,38 @@ module.exports = function(knex) {
}
}
});

it('select from subquery', async function() {
const subquery = knex.from('accounts').whereBetween('id', [3, 5]);
return knex
.pluck('id')
.orderBy('id')
.from(subquery)
.then(
(rows) => {
expect(rows).to.deep.equal([3, 4, 5]);
expect(knex.client.driverName).to.oneOf(['sqlite3', 'oracledb']);
},
(e) => {
switch (knex.client.driverName) {
case 'mysql':
case 'mysql2':
expect(e.errno).to.equal(1248);
break;
case 'pg':
expect(e.message).to.contain('must have an alias');
break;

case 'mssql':
expect(e.message).to.contain(
"Incorrect syntax near the keyword 'order'"
);
break;
default:
throw e;
}
}
);
});
});
};

0 comments on commit 1e996f7

Please sign in to comment.