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

Commit 1152e8eb by Mick Hansen

Merge pull request #3325 from braddunbar/in-literal

$in and $notIn support literals.
2 parents 34ff44cf 115600f4
......@@ -1749,7 +1749,9 @@ module.exports = (function() {
comparator = '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) {
return self.escape(item);
}).join(', ')+')';
......
......@@ -106,6 +106,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}, {
default: '[muscles] IN (2, 4)'
});
testsql('equipment', {
$in: current.literal(
'(select order_id from product_orders where product_id = 3)'
)
}, {
default: '[equipment] IN (select order_id from product_orders where product_id = 3)'
});
});
suite('Buffer', function () {
......@@ -151,6 +159,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}, {
default: '[equipment] NOT IN (4, 19)'
});
testsql('equipment', {
$notIn: current.literal(
'(select order_id from product_orders where product_id = 3)'
)
}, {
default: '[equipment] NOT IN (select order_id from product_orders where product_id = 3)'
});
});
suite('$ne', function () {
......@@ -448,4 +464,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!