不要怂,就是干,撸起袖子干!

Commit 2b166fe3 by Markus Hedlund Committed by Jan Aagaard Meier

Change behaviour for "$notIn empty array" (fixes #4859) (#4860)

* Change behaviour for "$notIn empty array"

* Make sure value in escape method is a string
1 parent ab1088e5
...@@ -2191,7 +2191,11 @@ var QueryGenerator = { ...@@ -2191,7 +2191,11 @@ var QueryGenerator = {
return self.escape(item); return self.escape(item);
}).join(', ')+')'; }).join(', ')+')';
} else { } else {
value = '(NULL)'; if (value.$in) {
value = '(NULL)';
} else {
return '';
}
} }
} else if (value && (value.$any || value.$all)) { } else if (value && (value.$any || value.$all)) {
comparator = value.$any ? '= ANY' : '= ALL'; comparator = value.$any ? '= ANY' : '= ALL';
......
...@@ -55,6 +55,10 @@ SqlString.escape = function(val, timeZone, dialect, format) { ...@@ -55,6 +55,10 @@ SqlString.escape = function(val, timeZone, dialect, format) {
return val.map(escape); return val.map(escape);
} }
if (!val.replace) {
throw new Error('Invalid value ' + val);
}
if (dialect === 'postgres' || dialect === 'sqlite' || dialect === 'mssql') { if (dialect === 'postgres' || dialect === 'sqlite' || dialect === 'mssql') {
// http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS // http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
// http://stackoverflow.com/q/603572/130598 // http://stackoverflow.com/q/603572/130598
......
...@@ -154,7 +154,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -154,7 +154,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql('equipment', { testsql('equipment', {
$notIn: [] $notIn: []
}, { }, {
default: '[equipment] NOT IN (NULL)' default: ''
}); });
testsql('equipment', { testsql('equipment', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!