sqlparser-devexpress 2.3.12 → 2.3.14

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.3.12",
3
+ "version": "2.3.14",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -10,4 +10,6 @@ export const OPERATOR_PRECEDENCE = {
10
10
  // Regular expression to check for unsupported SQL patterns (like SELECT-FROM or JOIN statements)
11
11
  export const UNSUPPORTED_PATTERN = /\bSELECT\b.*\bFROM\b|\bINNER\s+JOIN\b/i;
12
12
 
13
- export const LOGICAL_OPERATORS = ['and', 'or'];
13
+ export const LOGICAL_OPERATORS = ['and', 'or'];
14
+
15
+ export const LITERAL_TYPES = ["value", "placeholder"];
@@ -1,4 +1,4 @@
1
- import { LOGICAL_OPERATORS } from "../constants.js";
1
+ import { LITERAL_TYPES, LOGICAL_OPERATORS } from "../constants.js";
2
2
 
3
3
  /**
4
4
  * Main conversion function that sets up the global context
@@ -207,7 +207,7 @@ function DevExpressConverter() {
207
207
  }
208
208
 
209
209
  // handle short circuit evaluation for IN operator
210
- if (EnableShortCircuit && ast.field?.type === "value" && ast.value?.type === "value") {
210
+ if (EnableShortCircuit && (LITERAL_TYPES.includes(ast.field?.type) && LITERAL_TYPES.includes(ast.value?.type))) {
211
211
  const fieldVal = convertValue(ast.field);
212
212
  if (Array.isArray(resolvedValue)) {
213
213
  // normalize numeric strings if LHS is number
@@ -221,6 +221,16 @@ function DevExpressConverter() {
221
221
  return list.includes(fieldVal);
222
222
  else if (operator === "NOT IN")
223
223
  return !list.includes(fieldVal);
224
+ } else if (!Array.isArray(resolvedValue)) {
225
+ // normalize numeric strings if LHS is number
226
+ const value = (typeof resolvedValue === "string" && !isNaN(resolvedValue) && typeof fieldVal === "number")
227
+ ? Number(resolvedValue)
228
+ : resolvedValue;
229
+
230
+ if (operator === "IN")
231
+ return fieldVal == value;
232
+ else if (operator === "NOT IN")
233
+ return fieldVal != value;
224
234
  }
225
235
  }
226
236
 
@@ -216,11 +216,11 @@ describe("Parser SQL to dx Filter Builder", () => {
216
216
  expected: []
217
217
  },
218
218
  {
219
- input: "ID IN ('1,2') AND 0 IN ('0,2')",
219
+ input: "ID IN ({WorkOrderLine.CompanyIDs}) AND 0 IN ({WorkOrderLine.CompanyIDs})",
220
220
  expected: [
221
- ["ID", "=", "1"],
221
+ ["ID", "=", "0"],
222
222
  "or",
223
- ["ID", "=", "2"]
223
+ ["ID", "=", "1"]
224
224
  ]
225
225
  }
226
226
  ];
@@ -285,4 +285,5 @@ const sampleData = {
285
285
  "SupportResolution.TicketID": 123,
286
286
  "SaleOrderStatusStmtGlobalRpt.StateID": null,
287
287
  "SaleOrderStatusStmtGlobalRpt.RegionID": null,
288
+ "WorkOrderLine.CompanyIDs": ["0,1"],
288
289
  };