rusackas commented on code in PR #40607:
URL: https://github.com/apache/superset/pull/40607#discussion_r3343682599


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/agGridFilterConverter.ts:
##########
@@ -379,7 +379,15 @@ function simpleFilterToWhereClause(
   }
 
   if (type === FILTER_OPERATORS.IN_RANGE && filterTo !== undefined) {
-    return `${columnName} ${SQL_OPERATORS.BETWEEN} ${value} AND ${filterTo}`;
+    // Range bounds are interpolated into the clause without quoting, so they
+    // must be finite numbers. Coerce both ends and skip the clause entirely
+    // if either is not numeric.
+    const lowerBound = Number(value);
+    const upperBound = Number(filterTo);
+    if (!Number.isFinite(lowerBound) || !Number.isFinite(upperBound)) {
+      return '';
+    }
+    return `${columnName} ${SQL_OPERATORS.BETWEEN} ${lowerBound} AND 
${upperBound}`;
   }

Review Comment:
   Good catch, and thanks @sha174n for the suggestion. Addressed both issues: 
IN_RANGE is now handled unconditionally (so a missing/cleared upper bound is 
dropped instead of falling through to a single-operand BETWEEN), and a 
`toFiniteNumber` helper rejects `null`/`undefined`/empty-string bounds before 
coercion (since `Number("")` and `Number(null)` both yield `0`). Added 
regression tests for the non-numeric, empty-string, and missing-bound cases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to