mistercrunch closed pull request #5195: [sql lab] quote schema and table name
URL: https://github.com/apache/incubator-superset/pull/5195
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index eb3b3681eb..94f957b2f2 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -275,7 +275,7 @@ def where_latest_partition(
         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 @@ def select_star(cls, my_db, table_name, schema=None, 
limit=100,
         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 ebce5fcb31..467452015f 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -720,8 +720,10 @@ def select_star(
             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):


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to