From 3107152f5bb973b8b1a9c5cf3bc2bee1d7f47e0d Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 14 Mar 2017 16:00:52 -0700 Subject: [PATCH] Revert "Preprocess the where clauses." (#2411) * Revert "Display full name. (#2378)" This reverts commit 5b19528662f5ea645ead5b066144d69469ecbf7c. * Revert "Preprocess the where clauses. (#2405)" This reverts commit 357773c631ad39260109ec45d9c313d6d45cea89. --- superset/connectors/sqla/models.py | 1 - superset/db_engine_specs.py | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index fad3123bf2ef5..0ed21fcd7efb4 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -517,7 +517,6 @@ def visit_column(element, compiler, **kw): ) logging.info(sql) sql = sqlparse.format(sql, reindent=True) - sql = self.database.db_engine_spec.sql_preprocessor(sql) return sql def query(self, query_obj): diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py index e0a29304f63a2..533ae74e927c3 100644 --- a/superset/db_engine_specs.py +++ b/superset/db_engine_specs.py @@ -115,9 +115,9 @@ def extract_error_message(cls, e): def sql_preprocessor(cls, sql): """If the SQL needs to be altered prior to running it - For example db api needs to double `%` characters + For example Presto needs to double `%` characters """ - return sql.replace('%', '%%') + return sql @classmethod def patch(cls): @@ -279,6 +279,10 @@ def patch(cls): from superset.db_engines import presto as patched_presto presto.Cursor.cancel = patched_presto.cancel + @classmethod + def sql_preprocessor(cls, sql): + return sql.replace('%', '%%') + @classmethod def convert_dttm(cls, target_type, dttm): tt = target_type.upper()