From ffe30a160aff56e3d1fc0d4efb9bb323c387c4cb Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 11 Apr 2018 17:04:08 +0000 Subject: [PATCH] Fix druid_func tests --- superset/assets/src/utils/common.js | 25 +++++++++++++++++++++++++ superset/connectors/base/models.py | 2 +- superset/connectors/druid/models.py | 12 ++++++++---- tests/druid_func_tests.py | 4 ++-- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/superset/assets/src/utils/common.js b/superset/assets/src/utils/common.js index f2c3bd24ceff7..78942d9cc444c 100644 --- a/superset/assets/src/utils/common.js +++ b/superset/assets/src/utils/common.js @@ -103,3 +103,28 @@ export function isTruthy(obj) { } return !!obj; } + +export function optionLabel(opt) { + if (opt === null) { + return ''; + } else if (opt === '') { + return ''; + } else if (opt === true) { + return ''; + } else if (opt === false) { + return ''; + } + return opt; +} + +export function optionValue(opt) { + if (opt === null) { + return ''; + } + return opt; +} + +export function optionFromValue(opt) { + // From a list of options, handles special values & labels + return { value: optionValue(opt), label: optionLabel(opt) }; +} diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py index 143b75acf2bc5..87c0fc2c63ed7 100644 --- a/superset/connectors/base/models.py +++ b/superset/connectors/base/models.py @@ -192,7 +192,7 @@ def filter_values_handler( def handle_single_value(v): # backward compatibility with previous