sqlparser-devexpress 2.5.3 → 2.5.5

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.3",
3
+ "version": "2.5.5",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -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);
@@ -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
 
@@ -407,6 +407,40 @@ describe("Parser SQL to dx Filter Builder", () => {
407
407
  expected: [
408
408
  "AccountID", "=", 42
409
409
  ]
410
+ },
411
+ {
412
+ input: "ID IN ({SampleDoc.AuthFilterID})",
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
+ ]
410
444
  }
411
445
  ];
412
446
 
@@ -477,5 +511,9 @@ const sampleData = {
477
511
  "SaleOrderStatusStmtGlobalRpt.RegionID": null,
478
512
  "WorkOrderLine.CompanyIDs": ["0,1"],
479
513
  "PurchaseOrderDocument.IsMultiBrand": false,
480
- "PurchaseOrderDocument.AllowedApplicableMake": "0"
514
+ "PurchaseOrderDocument.AllowedApplicableMake": "0",
515
+ "SampleDoc.AuthFilterID": "ID",
516
+ "ItemPrice.AllowedItemGroupType": "1,2",
517
+ "ItemPrice.AllowedNonStock": 1,
518
+ "ItemPrice.CompanyID": 7
481
519
  };