Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

fix for empty NOT IN () in WHERE clause #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sequel/lib/criteriaProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ CriteriaProcessor.prototype.process = function process(parent, value, combinator
_param = utils.escapeName(self.currentTable, self.escapeCharacter) + '.' + utils.escapeName(parent, self.escapeCharacter);
}

// Check for an empty array to avoid issues with NOT IN ()
if ((key === '!' || key === 'not') && Array.isArray(obj[key]) && obj[key].length === 0) {
self.queryString += 'TRUE AND ';
return;
}

self.queryString += _param + ' ';
self.prepareCriterion(key, obj[key]);
self.queryString += ' AND ';
Expand Down