@@ -135,27 +135,30 @@ function DevExpressConverter() {
135135 }
136136
137137 const left = ast . left !== undefined ? processAstNode ( ast . left ) : convertValue ( ast . field ) ;
138+ const leftDefault = ast . left ?. args [ 1 ] ?. value ;
138139 const right = ast . right !== undefined ? processAstNode ( ast . right ) : convertValue ( ast . value ) ;
140+ const rightDefault = ast . right ?. args [ 1 ] ?. value ;
139141 let operatorToken = ast . operator . toLowerCase ( ) ;
140142
141- if ( operatorToken === "like" ) {
143+ if ( operatorToken === "like" ) {
142144 operatorToken = "contains" ;
143- } else if ( operatorToken === "not like" ) {
145+ } else if ( operatorToken === "not like" ) {
144146 operatorToken = "notcontains" ;
145147 }
146148
147149 let comparison = [ left , operatorToken , right ] ;
148150
151+ // Last null because of special case when using dropdown it https://github.com/DevExpress/DevExtreme/blob/25_1/packages/devextreme/js/__internal/data/m_utils.ts#L18 it takes last value as null
149152 if ( ( ast . left && isFunctionNullCheck ( ast . left , true ) ) || ( ast . value && isFunctionNullCheck ( ast . value , false ) ) ) {
150- comparison = [ [ left , operatorToken , right ] , 'or' , [ left , operatorToken , null , { type : "ISNULL" , defaultValue : ( ast . left ?? ast . value ) . args [ 1 ] ?. value } ] ] ;
153+ comparison = [ [ left , operatorToken , right ] , 'or' , [ left , operatorToken , null , { type : "ISNULL" , defaultValue : ( ast . left ?? ast . value ) . args [ 1 ] ?. value } , null ] ] ;
151154 } else if ( ast . right && isFunctionNullCheck ( ast . right , true ) ) {
152- comparison = [ [ left , operatorToken , right ] , 'or' , [ right , operatorToken , null , { type : "ISNULL" , defaultValue : ast . right . args [ 1 ] ?. value } ] ] ;
155+ comparison = [ [ left , operatorToken , right ] , 'or' , [ right , operatorToken , null , { type : "ISNULL" , defaultValue : ast . right . args [ 1 ] ?. value } , null ] ] ;
153156 }
154157
155158 // Apply short-circuit evaluation if enabled
156159 if ( EnableShortCircuit ) {
157- if ( isAlwaysTrue ( comparison ) ) return true ;
158- if ( isAlwaysFalse ( comparison ) ) return false ;
160+ if ( isAlwaysTrue ( comparison , leftDefault , rightDefault ) ) return true ;
161+ if ( isAlwaysFalse ( comparison , leftDefault , rightDefault ) ) return false ;
159162 }
160163
161164 return comparison ;
@@ -229,8 +232,8 @@ function DevExpressConverter() {
229232 if ( typeof val === "object" ) {
230233 if ( val . type === "placeholder" ) {
231234 const placeholderValue = resolvePlaceholderFromResultObject ( val . value ) ;
232-
233- if ( val ?. dataType === "string" ) {
235+
236+ if ( val ?. dataType === "string" ) {
234237 return placeholderValue ?. toString ( ) ;
235238 }
236239
@@ -331,29 +334,38 @@ function DevExpressConverter() {
331334 /**
332335 * Checks if a condition is always true.
333336 * @param {Array } condition - The condition to check.
337+ * @param {* } leftDefault - The default value for the left operand.
338+ * @param {* } rightDefault - The default value for the right operand.
334339 * @returns {boolean } True if the condition is always true.
335340 */
336- function isAlwaysTrue ( condition ) {
337- return Array . isArray ( condition ) && condition . length >= 3 && evaluateExpression ( ...condition ) == true ;
341+ function isAlwaysTrue ( condition , leftDefault , rightDefault ) {
342+ return Array . isArray ( condition ) && condition . length >= 3 && evaluateExpression ( ...condition , leftDefault , rightDefault ) == true ;
338343 }
339344
340345 /**
341346 * Checks if a condition is always false.
342347 * @param {Array } condition - The condition to check.
348+ * @param {* } leftDefault - The default value for the left operand.
349+ * @param {* } rightDefault - The default value for the right operand.
343350 * @returns {boolean } True if the condition is always false.
344351 */
345- function isAlwaysFalse ( condition ) {
346- return Array . isArray ( condition ) && condition . length >= 3 && evaluateExpression ( ...condition ) == false ;
352+ function isAlwaysFalse ( condition , leftDefault , rightDefault ) {
353+ return Array . isArray ( condition ) && condition . length >= 3 && evaluateExpression ( ...condition , leftDefault , rightDefault ) == false ;
347354 }
348355
349356 /**
350357 * Evaluates a simple expression.
351358 * @param {* } left - The left operand.
352359 * @param {string } operator - The operator.
353360 * @param {* } right - The right operand.
361+ * @param {* } leftDefault - The default value for the left operand.
362+ * @param {* } rightDefault - The default value for the right
354363 * @returns {boolean|null } The result of the evaluation or null if not evaluable.
355364 */
356- function evaluateExpression ( left , operator , right ) {
365+ function evaluateExpression ( left , operator , right , leftDefault , rightDefault ) {
366+ if ( left == null && leftDefault != undefined ) left = leftDefault ;
367+ if ( right == null && rightDefault != undefined ) right = rightDefault ;
368+
357369 if ( ( left !== null && isNaN ( left ) ) || ( right !== null && isNaN ( right ) ) ) return null ;
358370
359371 if ( left === null || right === null ) {
0 commit comments