From 206fdff6e9312279cf5762e1f40905a221fd8b24 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. (cherry picked from commit e213ccd4385a1496fa1af12a2d88bc9b411d332f) --- 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 56a1751243995..f5744c2b0a547 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -581,12 +581,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 6c5a2e8757313..35bbcea67032b 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -22,7 +22,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 @@ -367,7 +367,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()