sqlparser-devexpress 2.5.4 → 2.5.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sqlparser-devexpress",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -149,6 +149,20 @@ function DevExpressConverter() {
149
149
  const leftDefault = ast.left?.args && ast.left?.args[1]?.value;
150
150
  const right = ast.right !== undefined ? processAstNode(ast.right) : convertValue(ast.value);
151
151
  const rightDefault = ast.right?.args && ast.right?.args[1]?.value;
152
+
153
+ // Short-circuit when ISNULL's first arg is a placeholder (resolved concrete value, not a column).
154
+ // evaluateExpression cannot handle non-numeric string comparisons (e.g. "INV1" = ""),
155
+ // so detect and short-circuit here before any ISNULL column-null handling runs.
156
+ if (EnableShortCircuit && ast.left?.type === "function" && ast.left?.name === "ISNULL" &&
157
+ ast.left?.args?.[0]?.value?.type === "placeholder") {
158
+ if (IsValueNullShortCircuit && (left === null || right === null)) return true;
159
+ if (left !== null && right !== null) {
160
+ const normalL = normalizeBool(left);
161
+ const normalR = normalizeBool(right);
162
+ return normalL === normalR ? true : false;
163
+ }
164
+ }
165
+
152
166
  let operatorToken = ast.operator.toLowerCase();
153
167
  let includeExtradata = false;
154
168
 
@@ -164,6 +164,15 @@ export function parse(input, variables = []) {
164
164
  operator: newOperator,
165
165
  left: { type: "field", value: right }
166
166
  };
167
+ } else {
168
+ // Regular comparison where left is a parenthesized expression or function result
169
+ const right = parseValue(operator);
170
+ left = {
171
+ type: "comparison",
172
+ left: left,
173
+ operator: operator,
174
+ value: right
175
+ };
167
176
  }
168
177
  }
169
178
 
@@ -411,6 +411,51 @@ describe("Parser SQL to dx Filter Builder", () => {
411
411
  {
412
412
  input: "ID IN ({SampleDoc.AuthFilterID})",
413
413
  expected: []
414
+ },
415
+ {
416
+ input: "ItemGroupType IN ({ItemPrice.AllowedItemGroupType}) AND ((ISNULL(IsNonStock,0))={ItemPrice.AllowedNonStock}) AND (CompanyID = {ItemPrice.CompanyID} OR {ItemPrice.CompanyID} = 0 OR ISNULL(CompanyID,0) = 0)",
417
+ expected: [
418
+ [
419
+ [
420
+ ["ItemGroupType", "=", "1"],
421
+ "or",
422
+ ["ItemGroupType", "=", "2"]
423
+ ],
424
+ "and",
425
+ [
426
+ ["IsNonStock", "=", 1, { "defaultValue": 0, "position": "column", "type": "ISNULL" }, 1],
427
+ "or",
428
+ ["IsNonStock", "=", true]
429
+ ]
430
+ ],
431
+ "and",
432
+ [
433
+ ["CompanyID", "=", 7],
434
+ "or",
435
+ [
436
+ ["CompanyID", "=", 0],
437
+ "or",
438
+ ["CompanyID", "=", null, { "defaultValue": 0, "position": "column", "type": "ISNULL" }, null],
439
+ "or",
440
+ ["CompanyID", "=", false]
441
+ ]
442
+ ]
443
+ ],
444
+ },
445
+ {
446
+ input: "BranchID = {AdjustmentDocument.BranchID} AND CompanyID = {AdjustmentDocument.CompanyID} AND IsFromInvoice = {AdjustmentDocument.IsFromInvoice} AND (SupplierInvoiceNO IN ('{AdjustmentDocument.SupplierInvoiceNos}') OR ISNULL('{AdjustmentDocument.SupplierInvoiceNos}','''') = '''')",
447
+ expected: [
448
+ [
449
+ ["BranchID", "=", 42],
450
+ "and",
451
+ ["CompanyID", "=", 7],
452
+ "and",
453
+ ["IsFromInvoice", "=", true],
454
+ ],
455
+ "and",
456
+ ["SupplierInvoiceNO", "=", "INV1"]
457
+
458
+ ]
414
459
  }
415
460
  ];
416
461
 
@@ -482,5 +527,12 @@ const sampleData = {
482
527
  "WorkOrderLine.CompanyIDs": ["0,1"],
483
528
  "PurchaseOrderDocument.IsMultiBrand": false,
484
529
  "PurchaseOrderDocument.AllowedApplicableMake": "0",
485
- "SampleDoc.AuthFilterID": "ID"
530
+ "SampleDoc.AuthFilterID": "ID",
531
+ "ItemPrice.AllowedItemGroupType": "1,2",
532
+ "ItemPrice.AllowedNonStock": 1,
533
+ "ItemPrice.CompanyID": 7,
534
+ "AdjustmentDocument.BranchID": 42,
535
+ "AdjustmentDocument.CompanyID": 7,
536
+ "AdjustmentDocument.IsFromInvoice": true,
537
+ "AdjustmentDocument.SupplierInvoiceNos": "INV1"
486
538
  };