From bc5618406ddc6a0696cbb7f0334eb14f6ce0c1de Mon Sep 17 00:00:00 2001 From: John Bodley <4567245+john-bodley@users.noreply.github.com> Date: Mon, 7 Oct 2019 13:13:24 -0700 Subject: [PATCH] [dbapi] Fixing type ordering (#172) * [dbapi] Fixing type ordering * Update api.py --- pydruid/db/api.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pydruid/db/api.py b/pydruid/db/api.py index dd27ea94..9f3d5f97 100644 --- a/pydruid/db/api.py +++ b/pydruid/db/api.py @@ -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)) @@ -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):