Skip to content

Commit

Permalink
[dbapi] Fixing type ordering (#172)
Browse files Browse the repository at this point in the history
* [dbapi] Fixing type ordering

* Update api.py
  • Loading branch information
john-bodley authored and mistercrunch committed Oct 7, 2019
1 parent d574010 commit bc56184
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pydruid/db/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,18 @@ def get_description_from_row(row):


def get_type(value):
"""Infer type from value."""
"""
Infer type from value.
Note that bool is a subclass of int so order of statements matter.
"""

if isinstance(value, string_types) or value is None:
return Type.STRING
elif isinstance(value, (int, float)):
return Type.NUMBER
elif isinstance(value, bool):
return Type.BOOLEAN
elif isinstance(value, (int, float)):
return Type.NUMBER

raise exceptions.Error("Value of unknown type: {value}".format(value=value))

Expand Down Expand Up @@ -382,6 +387,12 @@ def apply_parameters(operation, parameters):


def escape(value):
"""
Escape the parameter value.
Note that bool is a subclass of int so order of statements matter.
"""

if value == "*":
return value
elif isinstance(value, string_types):
Expand Down

0 comments on commit bc56184

Please sign in to comment.