Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ export function parse(input, variables = []) {
operator: newOperator,
left: { type: "field", value: right }
};
} else {
// Regular comparison where left is a parenthesized expression or function result
const right = parseValue(operator);
left = {
type: "comparison",
left: left,
operator: operator,
value: right
};
}
}

Expand Down
39 changes: 37 additions & 2 deletions tests/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,40 @@ describe("Parser SQL to dx Filter Builder", () => {
expected: [
"AccountID", "=", 42
]
},
{
input: "ID IN ({SampleDoc.AuthFilterID})",
expected: []
},
{
input: "ItemGroupType IN ({ItemPrice.AllowedItemGroupType}) AND ((ISNULL(IsNonStock,0))={ItemPrice.AllowedNonStock}) AND (CompanyID = {ItemPrice.CompanyID} OR {ItemPrice.CompanyID} = 0 OR ISNULL(CompanyID,0) = 0)",
expected: [
[
[
["ItemGroupType", "=", "1"],
"or",
["ItemGroupType", "=", "2"]
],
"and",
[
["IsNonStock", "=", 1, { "defaultValue": 0, "position": "column", "type": "ISNULL" }, 1],
"or",
["IsNonStock", "=", true]
]
],
"and",
[
["CompanyID", "=", 7],
"or",
[
["CompanyID", "=", 0],
"or",
["CompanyID", "=", null, { "defaultValue": 0, "position": "column", "type": "ISNULL" }, null],
"or",
["CompanyID", "=", false]
]
]
]
}
];

Expand Down Expand Up @@ -479,6 +511,9 @@ const sampleData = {
"SaleOrderStatusStmtGlobalRpt.RegionID": null,
"WorkOrderLine.CompanyIDs": ["0,1"],
"PurchaseOrderDocument.IsMultiBrand": false,
"PurchaseOrderDocument.AllowedApplicableMake": "0"
"SampleDoc.AuthFilterID": "ID"
"PurchaseOrderDocument.AllowedApplicableMake": "0",
"SampleDoc.AuthFilterID": "ID",
"ItemPrice.AllowedItemGroupType": "1,2",
"ItemPrice.AllowedNonStock": 1,
"ItemPrice.CompanyID": 7
};