Fix bug in mongoQueryToFilter

This commit is contained in:
Zaid Abdulla committed 2019-10-29 13:01:47 -07:00
1 parent f135be403c
commit ab27ebfaef
2 files changed
+10 -3

No files matched your search

+6 -3
View File
@@ -522,9 +522,12 @@ export function mongoQueryToFilter(query): Expression {
} }
exps.push([op, ["PARAM", k], vv]); exps.push([op, ["PARAM", k], vv]);
} }
if (exps.length === 1) return exps[0]; if (exps.length === 1) {
const and: Expression = ["AND"]; expressions.push(exps[0]);
expressions.push(and.concat(exps)); } else {
const and: Expression = ["AND"];
expressions.push(and.concat(exps));
}
} else { } else {
expressions.push(["=", ["PARAM", k], v]); expressions.push(["=", ["PARAM", k], v]);
} }
+4
View File
@@ -32,6 +32,10 @@ ava("mongoQueryToFilter", t => {
[ [
{ test: { $gte: "test1", $ne: "test2" } }, { test: { $gte: "test1", $ne: "test2" } },
'test >= "test1" AND test <> "test2"' 'test >= "test1" AND test <> "test2"'
],
[
{ test: "test", test2: { $ne: "test2" } },
'test = "test" AND test2 <> "test2"'
] ]
]; ];