File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments