diff --git a/client/app/components/QueryBasedParameterInput.jsx b/client/app/components/QueryBasedParameterInput.jsx index b0743d6198..668cacab6e 100644 --- a/client/app/components/QueryBasedParameterInput.jsx +++ b/client/app/components/QueryBasedParameterInput.jsx @@ -66,7 +66,7 @@ export class QueryBasedParameterInput extends React.Component { className={className} disabled={loading || (options.length === 0)} loading={loading} - defaultValue={value} + defaultValue={'' + value} onChange={onSelect} dropdownMatchSelectWidth={false} dropdownClassName="ant-dropdown-in-bootstrap-modal" diff --git a/redash/utils/parameterized_query.py b/redash/utils/parameterized_query.py index 1c489ce456..c8f2cf37f9 100644 --- a/redash/utils/parameterized_query.py +++ b/redash/utils/parameterized_query.py @@ -13,7 +13,7 @@ def _pluck_name_and_value(default_column, row): name_column = "name" if "name" in row.keys() else default_column.lower() value_column = "value" if "value" in row.keys() else default_column.lower() - return {"name": row[name_column], "value": row[value_column]} + return {"name": row[name_column], "value": unicode(row[value_column])} def _load_result(query_id): diff --git a/tests/utils/test_parameterized_query.py b/tests/utils/test_parameterized_query.py index 24e2016b4e..ce020182bd 100644 --- a/tests/utils/test_parameterized_query.py +++ b/tests/utils/test_parameterized_query.py @@ -196,11 +196,11 @@ def test_dropdown_values_prefers_name_and_value_columns(self, _): "rows": [{"fish": "Clown", "id": 5, "poultry": "Hen"}]}) def test_dropdown_values_compromises_for_first_column(self, _): values = dropdown_values(1) - self.assertEquals(values, [{"name": 5, "value": 5}]) + self.assertEquals(values, [{"name": 5, "value": "5"}]) @patch('redash.utils.parameterized_query._load_result', return_value={ "columns": [{"name": "ID"}, {"name": "fish"}, {"name": "poultry"}], "rows": [{"fish": "Clown", "ID": 5, "poultry": "Hen"}]}) def test_dropdown_supports_upper_cased_columns(self, _): values = dropdown_values(1) - self.assertEquals(values, [{"name": 5, "value": 5}]) + self.assertEquals(values, [{"name": 5, "value": "5"}])