sqlparser-devexpress 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/core/converter.js +11 -1
- package/tests/parser.test.js +12 -1
package/package.json
CHANGED
package/src/core/converter.js
CHANGED
|
@@ -308,6 +308,13 @@ function DevExpressConverter() {
|
|
|
308
308
|
resolvedValue = resolvedValue.split(',').map(v => v.trim());
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
// Short-circuit: Field being compared to itself (e.g., ID IN (ID))
|
|
312
|
+
if (EnableShortCircuit && typeof ast.field === 'string') {
|
|
313
|
+
if (typeof resolvedValue === 'string' && ast.field === resolvedValue) {
|
|
314
|
+
return operator === "IN" ? true : false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
311
318
|
// handle short circuit evaluation for IN operator
|
|
312
319
|
if (EnableShortCircuit && (LITERAL_TYPES.includes(ast.field?.type) && LITERAL_TYPES.includes(ast.value?.type))) {
|
|
313
320
|
const fieldVal = convertValue(ast.field);
|
|
@@ -402,8 +409,11 @@ function DevExpressConverter() {
|
|
|
402
409
|
function resolvePlaceholderFromResultObject(placeholder) {
|
|
403
410
|
if (!resultObject) return `{${placeholder}}`;
|
|
404
411
|
|
|
412
|
+
// Case-insensitive lookup
|
|
413
|
+
const lowerPlaceholder = placeholder.toLowerCase();
|
|
414
|
+
const matchingKey = Object.keys(resultObject).find(key => key.toLowerCase() === lowerPlaceholder);
|
|
405
415
|
|
|
406
|
-
return
|
|
416
|
+
return matchingKey ? resultObject[matchingKey] : `{${placeholder.value ?? placeholder}}`;
|
|
407
417
|
}
|
|
408
418
|
|
|
409
419
|
/**
|
package/tests/parser.test.js
CHANGED
|
@@ -401,6 +401,16 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
401
401
|
"and",
|
|
402
402
|
["ItemGroupType", "=", "1"]
|
|
403
403
|
]
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
input: "AccountID = {AccountingRule.CompanyId}",
|
|
407
|
+
expected: [
|
|
408
|
+
"AccountID", "=", 42
|
|
409
|
+
]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
input: "ID IN ({SampleDoc.AuthFilterID})",
|
|
413
|
+
expected: []
|
|
404
414
|
}
|
|
405
415
|
];
|
|
406
416
|
|
|
@@ -471,5 +481,6 @@ const sampleData = {
|
|
|
471
481
|
"SaleOrderStatusStmtGlobalRpt.RegionID": null,
|
|
472
482
|
"WorkOrderLine.CompanyIDs": ["0,1"],
|
|
473
483
|
"PurchaseOrderDocument.IsMultiBrand": false,
|
|
474
|
-
"PurchaseOrderDocument.AllowedApplicableMake": "0"
|
|
484
|
+
"PurchaseOrderDocument.AllowedApplicableMake": "0",
|
|
485
|
+
"SampleDoc.AuthFilterID": "ID"
|
|
475
486
|
};
|