sqlparser-devexpress 2.5.7 → 2.5.9
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 +1 -1
- package/src/core/converter.js +6 -5
- package/tests/parser.test.js +29 -2
package/package.json
CHANGED
package/src/core/converter.js
CHANGED
|
@@ -238,7 +238,12 @@ function DevExpressConverter() {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
// Apply short-circuit evaluation if enabled
|
|
241
|
-
|
|
241
|
+
// Skip for "IS NOT" (e.g. "col IS NOT NULL"): its null is a literal from the query
|
|
242
|
+
// itself, not a placeholder resolving to null, so it must remain a real filter.
|
|
243
|
+
// Avoid null short-circuit when comparison is produced from ISNULL(column, default),
|
|
244
|
+
// otherwise OR branches like ISNULL(CompanyID,0)=param OR ISNULL(CompanyID,0)=0
|
|
245
|
+
// can collapse to a full-match filter when param is null.
|
|
246
|
+
if (EnableShortCircuit && IsValueNullShortCircuit && originalOperator !== "IS NOT" && (left == null || right == null) && !isLeftNullCheck && !isRightNullCheck) {
|
|
242
247
|
return true; // If either value is null, return true for short-circuit evaluation
|
|
243
248
|
}
|
|
244
249
|
|
|
@@ -357,10 +362,6 @@ function DevExpressConverter() {
|
|
|
357
362
|
}
|
|
358
363
|
}
|
|
359
364
|
|
|
360
|
-
if (EnableShortCircuit && IsValueNullShortCircuit && (ast.field?.type === "placeholder" || ast.value?.type === "placeholder" || ast.value === null) && resolvedValue === null) {
|
|
361
|
-
return true;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
365
|
let operatorToken = operator === "IN" ? '=' : operator === "NOT IN" ? '!=' : operator;
|
|
365
366
|
let joinOperatorToken = operator === "IN" ? 'or' : operator === "NOT IN" ? 'and' : operator;
|
|
366
367
|
let field = convertValue(ast.field);
|
package/tests/parser.test.js
CHANGED
|
@@ -276,7 +276,7 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
278
|
input: "ID IN ({SaleOrderStatusStmtGlobalRpt.RegionID})",
|
|
279
|
-
expected: []
|
|
279
|
+
expected: ["ID","=",null]
|
|
280
280
|
},
|
|
281
281
|
{
|
|
282
282
|
input: "10 < ID AND ApplicableUoms IN ({WorkOrderLine.ApplicableUoms})",
|
|
@@ -478,6 +478,30 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
478
478
|
["SupplierInvoiceNO", "=", "INV1"]
|
|
479
479
|
|
|
480
480
|
]
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
input: `DocType IN ({QuoteDocument.AllowedDocType})
|
|
484
|
+
AND CompanyID = {QuoteDocument.CompanyID}
|
|
485
|
+
AND
|
|
486
|
+
(
|
|
487
|
+
{QuoteDocument.IsVehicle} = 0
|
|
488
|
+
OR
|
|
489
|
+
(
|
|
490
|
+
{QuoteDocument.IsVehicle} = 1
|
|
491
|
+
AND ProspectID IS NOT NULL
|
|
492
|
+
)
|
|
493
|
+
)`,
|
|
494
|
+
expected: [
|
|
495
|
+
[
|
|
496
|
+
["DocType", "=", "10809"],
|
|
497
|
+
"or",
|
|
498
|
+
["DocType", "=", "40927"]
|
|
499
|
+
],
|
|
500
|
+
"and",
|
|
501
|
+
["CompanyID", "=", 2],
|
|
502
|
+
"and",
|
|
503
|
+
["ProspectID", "!=", null, { "type": "IS NOT" }, null]
|
|
504
|
+
]
|
|
481
505
|
}
|
|
482
506
|
];
|
|
483
507
|
|
|
@@ -558,5 +582,8 @@ const sampleData = {
|
|
|
558
582
|
"AdjustmentDocument.BranchID": 42,
|
|
559
583
|
"AdjustmentDocument.CompanyID": 7,
|
|
560
584
|
"AdjustmentDocument.IsFromInvoice": true,
|
|
561
|
-
"AdjustmentDocument.SupplierInvoiceNos": "INV1"
|
|
585
|
+
"AdjustmentDocument.SupplierInvoiceNos": "INV1",
|
|
586
|
+
"QuoteDocument.AllowedDocType": "10809,40927",
|
|
587
|
+
"QuoteDocument.CompanyID": 2,
|
|
588
|
+
"QuoteDocument.IsVehicle": true
|
|
562
589
|
};
|