sqlparser-devexpress 2.5.9 → 2.6.0

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.9",
3
+ "version": "2.6.0",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -108,6 +108,7 @@ function DevExpressConverter() {
108
108
 
109
109
  // Short-circuit: always-false conditions
110
110
  if (left === false || right === false) {
111
+ if (operator === 'and') return false;
111
112
  return left === false ? right : left;
112
113
  }
113
114
  }
@@ -244,6 +245,11 @@ function DevExpressConverter() {
244
245
  // otherwise OR branches like ISNULL(CompanyID,0)=param OR ISNULL(CompanyID,0)=0
245
246
  // can collapse to a full-match filter when param is null.
246
247
  if (EnableShortCircuit && IsValueNullShortCircuit && originalOperator !== "IS NOT" && (left == null || right == null) && !isLeftNullCheck && !isRightNullCheck) {
248
+ // No column involved (e.g. {var} = 0): evaluate null against the value instead of dropping it.
249
+ if (typeof ast.field !== "string") {
250
+ const evaluated = evaluateExpression(left, operatorToken, right, leftDefault, rightDefault);
251
+ if (evaluated === true || evaluated === false) return evaluated;
252
+ }
247
253
  return true; // If either value is null, return true for short-circuit evaluation
248
254
  }
249
255
 
@@ -549,10 +555,7 @@ function DevExpressConverter() {
549
555
 
550
556
  if ((left !== null && isNaN(left)) || (right !== null && isNaN(right))) return null;
551
557
 
552
- // Handle NULL == 0 OR NULL == "" cases
553
- if (left === null && (right == 0 || right == "")) return true;
554
- if (right === null && (left == 0 || left == "")) return true;
555
-
558
+ // NULL only equals NULL (NULL = 0 is false); use ISNULL(x, 0) to treat NULL as 0
556
559
  if (left === null || right === null) {
557
560
  if (operator === '=' || operator === '==') return left === right;
558
561
  if (operator === '<>' || operator === '!=') return left !== right;
@@ -99,8 +99,11 @@ export function parse(input, variables = []) {
99
99
  if (currentToken && currentToken.type === "operator") {
100
100
  const operator = currentToken.value;
101
101
  next(); // Move to the next token after the operator
102
- const rightOperand = parseValue(); // Parse the value after the operator
103
102
  const nodeType = LOGICAL_OPERATORS.includes(operator.toLowerCase()) ? "logical" : "comparison";
103
+ // After AND / OR the right side is a full expression (e.g. "(a = 1)" or "a = 1"), not a single value
104
+ const rightOperand = nodeType === "logical"
105
+ ? parseExpression(OPERATOR_PRECEDENCE[operator.toUpperCase()] + 1)
106
+ : parseValue(); // Parse the value after the operator
104
107
 
105
108
  if (nodeType === "logical") {
106
109
  return { type: "logical", operator, left: { type: "function", name: functionName, args: functionArgs }, right: rightOperand };