From 8a8b4ece93c464941a1f20b3c64485bc76648a29 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 2 May 2018 15:24:44 -0700 Subject: [PATCH] [bufix] filtered column was removed (#4921) if a filter is created on a chart, and the column is removed from the dataset, you get a "'NoneType' object has no attribute 'is_num'" or something to that effect. This fix disregards the filter. Also error messages were HTML escaped which React does already anyways so that's not necessary [anymore] here. --- superset/assets/src/chart/chartAction.js | 1 + superset/connectors/sqla/models.py | 10 +++++----- superset/viz.py | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/superset/assets/src/chart/chartAction.js b/superset/assets/src/chart/chartAction.js index a2f01165d61ce..f1112f5a8dcdd 100644 --- a/superset/assets/src/chart/chartAction.js +++ b/superset/assets/src/chart/chartAction.js @@ -2,6 +2,7 @@ import { getExploreUrlAndPayload, getAnnotationJsonUrl } from '../explore/explor import { requiresQuery, ANNOTATION_SOURCE_TYPES } from '../modules/AnnotationTypes'; import { Logger, LOG_ACTIONS_LOAD_EVENT } from '../logger'; import { COMMON_ERR_MESSAGES } from '../common'; +import { t } from '../locales'; const $ = window.$ = require('jquery'); diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 9d6f57b4554dc..269b087414b8e 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -582,12 +582,12 @@ def get_sqla_query( # sqla col = flt['col'] op = flt['op'] col_obj = cols.get(col) - is_list_target = op in ('in', 'not in') - eq = self.filter_values_handler( - flt.get('val'), - target_column_is_numeric=col_obj.is_num, - is_list_target=is_list_target) if col_obj: + is_list_target = op in ('in', 'not in') + eq = self.filter_values_handler( + flt.get('val'), + target_column_is_numeric=col_obj.is_num, + is_list_target=is_list_target) if op in ('in', 'not in'): cond = col_obj.sqla_col.in_(eq) if '' in eq: diff --git a/superset/viz.py b/superset/viz.py index de14f1af24f7e..7eb34c68c639f 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -23,7 +23,7 @@ import uuid from dateutil import relativedelta as rdelta -from flask import escape, request +from flask import request from flask_babel import lazy_gettext as _ import geohash from geopy.point import Point @@ -368,7 +368,7 @@ def get_df_payload(self, query_obj=None): except Exception as e: logging.exception(e) if not self.error_message: - self.error_message = escape('{}'.format(e)) + self.error_message = '{}'.format(e) self.status = utils.QueryStatus.FAILED stacktrace = traceback.format_exc()