Skip to content

Commit

Permalink
fix(QueryBuilder): support falsy values in between pairs (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
targos authored Jun 13, 2020
1 parent ff9fb2e commit 2d2e7cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Database/QueryBuilder/Chainable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export abstract class Chainable extends Macroable implements ChainableContract {
*/
private getBetweenPair (value: any[]): any {
const [lhs, rhs] = value
if (!lhs || !rhs) {
if (lhs === undefined || rhs === undefined) {
throw new Error('Invalid array for whereBetween value')
}

Expand Down
4 changes: 2 additions & 2 deletions test/database/query-builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2051,12 +2051,12 @@ test.group('Query Builder | whereBetween', (group) => {
let db = getQueryBuilder(getQueryClient(connection))
const { sql, bindings } = db
.from('users')
.whereBetween('age', [18, 20])
.whereBetween('age', [0, 20])
.toSQL()

const { sql: knexSql, bindings: knexBindings } = connection.client!
.from('users')
.whereBetween('age', [18, 20])
.whereBetween('age', [0, 20])
.toSQL()

assert.equal(sql, knexSql)
Expand Down

0 comments on commit 2d2e7cb

Please sign in to comment.