Skip to content

Commit 5ac4ee6

Browse files
author
Ruben Nogueira
committed
fix: invalid filter
1 parent f91dee6 commit 5ac4ee6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/sql.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,17 +1125,19 @@ SQLConnector.prototype._buildWhere = function(model, where) {
11251125
if (Array.isArray(clauses)) {
11261126
for (let i = 0, n = clauses.length; i < n; i++) {
11271127
const stmtForClause = self._buildWhere(model, clauses[i]);
1128-
if (stmtForClause.sql) {
1128+
if (stmtForClause.sql) { // first case, getting into ()
11291129
stmtForClause.sql = '(' + stmtForClause.sql + ')';
11301130
branchParams = branchParams.concat(stmtForClause.params);
11311131
branches.push(stmtForClause.sql);
11321132
}
11331133
}
1134-
stmt.merge({
1135-
sql: '(' + branches.join(' ' + key.toUpperCase() + ' ') + ')',
1136-
params: branchParams,
1137-
});
1138-
whereStmts.push(stmt);
1134+
if (branches.length > 0) {
1135+
stmt.merge({
1136+
sql: '(' + branches.join(' ' + key.toUpperCase() + ' ') + ')',
1137+
params: branchParams,
1138+
});
1139+
whereStmts.push(stmt);
1140+
}
11391141
continue;
11401142
}
11411143
// The value is not an array, fall back to regular fields

0 commit comments

Comments
 (0)