Skip to content

Commit

Permalink
ParameterizedQuery: handle the case where a value is null (#4072)
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr authored Aug 15, 2019
1 parent 2c2f241 commit 0e90b89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion redash/models/parameterized_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _is_date(string):
try:
parse(string)
return True
except ValueError:
except (ValueError, TypeError):
return False


Expand Down
7 changes: 7 additions & 0 deletions tests/models/test_parameterized_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def test_raises_on_invalid_date_parameters(self):
with pytest.raises(InvalidParameterError):
query.apply({"bar": "baz"})

def test_raises_on_none_for_date_parameters(self):
schema = [{"name": "bar", "type": "date"}]
query = ParameterizedQuery("foo", schema)

with pytest.raises(InvalidParameterError):
query.apply({"bar": None})

def test_validates_date_parameters(self):
schema = [{"name": "bar", "type": "date"}]
query = ParameterizedQuery("foo {{bar}}", schema)
Expand Down

0 comments on commit 0e90b89

Please sign in to comment.