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

Commit dd388240 by Brad Dunbar

$in and $notIn support literals.

1 parent 96380d2e
...@@ -1743,7 +1743,9 @@ module.exports = (function() { ...@@ -1743,7 +1743,9 @@ module.exports = (function() {
comparator = 'IN'; comparator = 'IN';
if (value.$notIn) comparator = 'NOT IN'; if (value.$notIn) comparator = 'NOT IN';
if ((value.$in || value.$notIn).length) { if ((value.$in || value.$notIn) instanceof Utils.literal) {
value = (value.$in || value.$notIn).val;
} else if ((value.$in || value.$notIn).length) {
value = '('+(value.$in || value.$notIn).map(function (item) { value = '('+(value.$in || value.$notIn).map(function (item) {
return self.escape(item); return self.escape(item);
}).join(', ')+')'; }).join(', ')+')';
......
...@@ -106,6 +106,12 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -106,6 +106,12 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}, { }, {
default: '[muscles] IN (2, 4)' default: '[muscles] IN (2, 4)'
}); });
testsql('equipment', {
$in: current.literal('(1, 2)')
}, {
default: '[equipment] IN (1, 2)'
});
}); });
suite('Buffer', function () { suite('Buffer', function () {
...@@ -151,6 +157,12 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -151,6 +157,12 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}, { }, {
default: '[equipment] NOT IN (4, 19)' default: '[equipment] NOT IN (4, 19)'
}); });
testsql('equipment', {
$notIn: current.literal('(1, 2)')
}, {
default: '[equipment] NOT IN (1, 2)'
});
}); });
suite('$ne', function () { suite('$ne', function () {
...@@ -436,4 +448,4 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -436,4 +448,4 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}); });
} }
}); });
}); });
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!