You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/03/08 06:15:33 UTC
[GitHub] [superset] ktmud commented on a change in pull request #13496: fix: `IS NULL` filter operator for numeric columns
ktmud commented on a change in pull request #13496:
URL: https://github.com/apache/superset/pull/13496#discussion_r589191076
##########
File path: superset-frontend/src/explore/exploreUtils.js
##########
@@ -319,20 +320,14 @@ export const getSimpleSQLExpression = (subject, operator, comparator) => {
expression += ` ${operator}`;
const firstValue =
isMulti && Array.isArray(comparator) ? comparator[0] : comparator;
- let comparatorArray;
- if (comparator === undefined || comparator === null) {
- comparatorArray = [];
- } else if (Array.isArray(comparator)) {
- comparatorArray = comparator;
- } else {
- comparatorArray = [comparator];
- }
+ const comparatorArray = ensureIsArray(comparator);
const isString =
firstValue !== undefined && Number.isNaN(Number(firstValue));
const quote = isString ? "'" : '';
const [prefix, suffix] = isMulti ? ['(', ')'] : ['', ''];
const formattedComparators = comparatorArray.map(
- val => `${quote}${isString ? val.replace("'", "''") : val}${quote}`,
+ val =>
+ `${quote}${isString ? String(val).replace("'", "''") : val}${quote}`,
Review comment:
This fixes a rare case when `<NULL>` is used as the first filter value for a numeric column, saving the filter will throw a JS error:

----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org