sqlparser-devexpress 2.5.1 → 2.5.3

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.1",
3
+ "version": "2.5.3",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "types": "src/@types/default.d.ts",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/RohitM-IN/SQLParser.git"
16
+ "url": "git+https://github.com/RohitM-IN/SQLParser.git"
17
17
  },
18
18
  "keywords": [
19
19
  "sql",
@@ -402,8 +402,11 @@ function DevExpressConverter() {
402
402
  function resolvePlaceholderFromResultObject(placeholder) {
403
403
  if (!resultObject) return `{${placeholder}}`;
404
404
 
405
+ // Case-insensitive lookup
406
+ const lowerPlaceholder = placeholder.toLowerCase();
407
+ const matchingKey = Object.keys(resultObject).find(key => key.toLowerCase() === lowerPlaceholder);
405
408
 
406
- return resultObject.hasOwnProperty(placeholder) ? resultObject[placeholder] : `{${placeholder.value ?? placeholder}}`;
409
+ return matchingKey ? resultObject[matchingKey] : `{${placeholder.value ?? placeholder}}`;
407
410
  }
408
411
 
409
412
  /**
@@ -518,13 +521,17 @@ function DevExpressConverter() {
518
521
  return null; // Any comparison with null should return null
519
522
  }
520
523
 
524
+ // Normalize boolean values to numbers for comparison with numbers
525
+ const normalizedLeft = normalizeBool(left);
526
+ const normalizedRight = normalizeBool(right);
527
+
521
528
  switch (operator) {
522
- case '=': case '==': return left === right;
523
- case '<>': case '!=': return left !== right;
524
- case '>': return left > right;
525
- case '>=': return left >= right;
526
- case '<': return left < right;
527
- case '<=': return left <= right;
529
+ case '=': case '==': return normalizedLeft === normalizedRight;
530
+ case '<>': case '!=': return normalizedLeft !== normalizedRight;
531
+ case '>': return normalizedLeft > normalizedRight;
532
+ case '>=': return normalizedLeft >= normalizedRight;
533
+ case '<': return normalizedLeft < normalizedRight;
534
+ case '<=': return normalizedLeft <= normalizedRight;
528
535
  default: return null; // Invalid operator
529
536
  }
530
537
  }
@@ -388,6 +388,24 @@ describe("Parser SQL to dx Filter Builder", () => {
388
388
  ["AllowSubDealer", "=", true],
389
389
  'or',
390
390
  ["AllowSubDealer", "=", null, { "type": "ISNULL", "position": "column", "defaultValue": 1 }, null]
391
+ ],
392
+ },
393
+ {
394
+ input: "(CompanyID = {LeadDocument.CompanyID} OR CompanyID IS NULL) AND ItemGroupType IN ({Item.AllowedItemGroupTypeOne}) AND ({PurchaseOrderDocument.IsMultiBrand} = 0 OR ({PurchaseOrderDocument.IsMultiBrand} = 1 AND Make IN ({PurchaseOrderDocument.AllowedApplicableMake})))",
395
+ expected: [
396
+ [
397
+ ["CompanyID", "=", 7],
398
+ "or",
399
+ ["CompanyID", "=", null, { "type": "IS" }, null]
400
+ ],
401
+ "and",
402
+ ["ItemGroupType", "=", "1"]
403
+ ]
404
+ },
405
+ {
406
+ input: "AccountID = {AccountingRule.CompanyId}",
407
+ expected: [
408
+ "AccountID", "=", 42
391
409
  ]
392
410
  }
393
411
  ];
@@ -428,6 +446,7 @@ describe("Parser SQL to dx Filter Builder", () => {
428
446
 
429
447
 
430
448
  const sampleData = {
449
+ "Example.ZeroValue": 0,
431
450
  "CoreEntity0022.CompanyGroupID": 42,
432
451
  "CoreEntity0022.BranchID": 7,
433
452
  "Employee.District": 0,
@@ -441,6 +460,7 @@ const sampleData = {
441
460
  "Item.ID": 42,
442
461
  "Item.BranchID": 7,
443
462
  "Item.AllowedItemGroupType": "1,2",
463
+ "Item.AllowedItemGroupTypeOne": "1",
444
464
  "WorkOrderLine.ApplicableUoms": ["UOM1", "UOM2", "UOM3"],
445
465
  "WorkOrderLine.CompanyID": 2,
446
466
  "WorkOrderDocument.CompanyID": 42,
@@ -456,4 +476,6 @@ const sampleData = {
456
476
  "SaleOrderStatusStmtGlobalRpt.StateID": null,
457
477
  "SaleOrderStatusStmtGlobalRpt.RegionID": null,
458
478
  "WorkOrderLine.CompanyIDs": ["0,1"],
479
+ "PurchaseOrderDocument.IsMultiBrand": false,
480
+ "PurchaseOrderDocument.AllowedApplicableMake": "0"
459
481
  };