Skip to content

Commit

Permalink
Fix issue with select(0) (#2711)
Browse files Browse the repository at this point in the history
* Fix issue with select(0). Fixes #2658
  • Loading branch information
Simon Lidén authored and tgriesser committed Jul 13, 2018
1 parent 6f11eb1 commit 0f4c9bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/query/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ assign(Builder.prototype, {
// Adds a column or columns to the list of "columns"
// being selected on the query.
columns(column) {
if (!column) return this;
if (!column && column !== 0) return this;
this._statements.push({
grouping: 'columns',
value: helpers.normalizeArr.apply(null, arguments),
Expand Down
10 changes: 10 additions & 0 deletions test/unit/query/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8139,4 +8139,14 @@ describe('QueryBuilder', function() {
);
});
});

it('Can call knex.select(0)', function() {
testquery(qb().select(0), {
pg: 'select 0',
mysql: 'select 0',
mssql: 'select 0',
'pg-redshift': 'select 0',
oracledb: 'select 0',
});
});
});

0 comments on commit 0f4c9bd

Please sign in to comment.