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

Preprocess the where clauses. #2405

Merged
merged 1 commit into from
Mar 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ 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):
Expand Down
8 changes: 2 additions & 6 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 Presto needs to double `%` characters
For example db api needs to double `%` characters
"""
return sql
return sql.replace('%', '%%')

@classmethod
def patch(cls):
Expand Down Expand Up @@ -279,10 +279,6 @@ 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()
Expand Down