You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2018/06/18 15:42:11 UTC

[incubator-superset] branch master updated: [sql lab] quote schema and table name (#5195)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new c89933d  [sql lab] quote schema and table name (#5195)
c89933d is described below

commit c89933d870fe2df7512114581c25cbdbe66cf9e0
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Jun 18 08:42:08 2018 -0700

    [sql lab] quote schema and table name (#5195)
    
    fixes https://github.com/apache/incubator-superset/issues/4595
---
 superset/db_engine_specs.py | 9 +++++++--
 superset/models/core.py     | 4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index eb3b368..94f957b 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -275,7 +275,7 @@ class BaseEngineSpec(object):
         return False
 
     @classmethod
-    def select_star(cls, my_db, table_name, schema=None, limit=100,
+    def select_star(cls, my_db, table_name, engine, schema=None, limit=100,
                     show_cols=False, indent=True, latest_partition=True,
                     cols=None):
         fields = '*'
@@ -286,9 +286,14 @@ class BaseEngineSpec(object):
         if show_cols:
             fields = [sqla.column(c.get('name')) for c in cols]
         full_table_name = table_name
+        quote = engine.dialect.identifier_preparer.quote
         if schema:
-            full_table_name = schema + '.' + table_name
+            full_table_name = quote(schema) + '.' + quote(table_name)
+        else:
+            full_table_name = quote(table_name)
+
         qry = select(fields).select_from(text(full_table_name))
+
         if limit:
             qry = qry.limit(limit)
         if latest_partition:
diff --git a/superset/models/core.py b/superset/models/core.py
index ebce5fc..4674520 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -720,8 +720,10 @@ class Database(Model, AuditMixinNullable, ImportMixin):
             self, table_name, schema=None, limit=100, show_cols=False,
             indent=True, latest_partition=True, cols=None):
         """Generates a ``select *`` statement in the proper dialect"""
+        eng = self.get_sqla_engine(schema=schema)
         return self.db_engine_spec.select_star(
-            self, table_name, schema=schema, limit=limit, show_cols=show_cols,
+            self, table_name, schema=schema, engine=eng,
+            limit=limit, show_cols=show_cols,
             indent=indent, latest_partition=latest_partition, cols=cols)
 
     def apply_limit_to_sql(self, sql, limit=1000):

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.