Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all dropdown values to strings to support parameter lookup #3563

Merged
merged 4 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redash/utils/parameterized_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": str(row[value_column])}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unicode(row[...])?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Y U NO SUGGEST CHANGE



def _load_result(query_id):
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/test_parameterized_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}])