mirror of https://github.com/apache/superset.git
[sql lab] quote schema and table name (#5195)
fixes https://github.com/apache/incubator-superset/issues/4595
This commit is contained in:
parent
ccf211036d
commit
c89933d870
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue