@@ -8,6 +8,7 @@ function DevExpressConverter() {
88 // Global variables accessible throughout the converter
99 let resultObject = null ;
1010 let EnableShortCircuit = true ;
11+ let IsValueNullShortCircuit = false ; // Flag to enable/disable null short-circuiting
1112
1213 /**
1314 * Main conversion function that sets up the global context
@@ -16,10 +17,11 @@ function DevExpressConverter() {
1617 * @param {boolean } enableShortCircuit - Optional enabling and disabling the shortcircuit ie evaluating value = value scenario
1718 * @returns {Array|null } DevExpress format filter
1819 */
19- function convert ( ast , ResultObject = null , enableShortCircuit = true ) {
20+ function convert ( ast , ResultObject = null , enableShortCircuit = true , isValueNullShortCircuit = false ) {
2021 // Set up global context
2122 resultObject = ResultObject ;
2223 EnableShortCircuit = enableShortCircuit ;
24+ IsValueNullShortCircuit = isValueNullShortCircuit ;
2325
2426 // Process the AST
2527 let result = processAstNode ( ast ) ;
@@ -89,6 +91,7 @@ function DevExpressConverter() {
8991 const left = processAstNode ( ast . left , operator ) ;
9092 const right = processAstNode ( ast . right , operator ) ;
9193
94+
9295 if ( EnableShortCircuit ) {
9396 // Short-circuit: always-true conditions
9497 if ( left === true || right === true ) {
@@ -100,7 +103,6 @@ function DevExpressConverter() {
100103 if ( left === false || right === false ) {
101104 return left === false ? right : left ;
102105 }
103-
104106 }
105107
106108 // Detect and flatten nested logical expressions
@@ -165,6 +167,10 @@ function DevExpressConverter() {
165167 }
166168
167169 // Apply short-circuit evaluation if enabled
170+ if ( EnableShortCircuit && IsValueNullShortCircuit && ( left == null || right == null ) ) {
171+ return true ; // If either value is null, return true for short-circuit evaluation
172+ }
173+
168174 if ( EnableShortCircuit ) {
169175 if ( isAlwaysTrue ( comparison , leftDefault , rightDefault ) ) return true ;
170176 if ( isAlwaysFalse ( comparison , leftDefault , rightDefault ) ) return false ;
@@ -242,6 +248,10 @@ function DevExpressConverter() {
242248 }
243249 }
244250
251+ if ( EnableShortCircuit && IsValueNullShortCircuit && ( ast . field ?. type === "placeholder" || ast . value ?. type === "placeholder" || ast . value === null ) && resolvedValue === null ) {
252+ return true ;
253+ }
254+
245255 let operatorToken = operator === "IN" ? '=' : operator === "NOT IN" ? '!=' : operator ;
246256 let joinOperatorToken = operator === "IN" ? 'or' : operator === "NOT IN" ? 'and' : operator ;
247257 let field = convertValue ( ast . field ) ;
@@ -443,8 +453,9 @@ const devExpressConverter = DevExpressConverter();
443453 * @param {Object } ast - The abstract syntax tree
444454 * @param {Object } resultObject - Optional object for placeholder resolution
445455 * @param {string } enableShortCircuit - Optional enabling and disabling the shortcircuit ie evaluating value = value scenario
456+ * @param {boolean } isValueNullShortCircuit - Optional enabling and disabling the null shortcircuit ie evaluating value = null scenario
446457 * @returns {Array|null } DevExpress format filter
447458 */
448- export function convertToDevExpressFormat ( { ast, resultObject = null , enableShortCircuit = true } ) {
449- return devExpressConverter . init ( ast , resultObject , enableShortCircuit ) ;
459+ export function convertToDevExpressFormat ( { ast, resultObject = null , enableShortCircuit = true , isValueNullShortCircuit = false } ) {
460+ return devExpressConverter . init ( ast , resultObject , enableShortCircuit , isValueNullShortCircuit ) ;
450461}
0 commit comments