mirror of https://github.com/apache/superset.git
parent
3f124d9d67
commit
50d2e5a15d
|
@ -134,7 +134,9 @@ include-naming-hint=no
|
|||
|
||||
# List of decorators that produce properties, such as abc.abstractproperty. Add
|
||||
# to this list to register other decorators that produce valid properties.
|
||||
property-classes=abc.abstractproperty
|
||||
property-classes=
|
||||
abc.abstractproperty,
|
||||
sqlalchemy.ext.hybrid.hybrid_property
|
||||
|
||||
# Regular expression matching correct argument names
|
||||
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
|
|
@ -66,6 +66,7 @@ from sqlalchemy import (
|
|||
update,
|
||||
)
|
||||
from sqlalchemy.engine.base import Connection
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
from sqlalchemy.orm import backref, Query, relationship, RelationshipProperty, Session
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from sqlalchemy.orm.mapper import Mapper
|
||||
|
@ -741,7 +742,7 @@ class SqlaTable(Model, BaseDatasource): # pylint: disable=too-many-public-metho
|
|||
"MAX": sa.func.MAX,
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
def __repr__(self) -> str: # pylint: disable=invalid-repr-returned
|
||||
return self.name
|
||||
|
||||
@staticmethod
|
||||
|
@ -835,11 +836,9 @@ class SqlaTable(Model, BaseDatasource): # pylint: disable=too-many-public-metho
|
|||
raise DatasetInvalidPermissionEvaluationException()
|
||||
return f"[{self.database}].[{self.table_name}](id:{self.id})"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
if not self.schema:
|
||||
return self.table_name
|
||||
return "{}.{}".format(self.schema, self.table_name)
|
||||
@hybrid_property
|
||||
def name(self) -> str: # pylint: disable=invalid-overridden-method
|
||||
return self.schema + "." + self.table_name if self.schema else self.table_name
|
||||
|
||||
@property
|
||||
def full_name(self) -> str:
|
||||
|
|
|
@ -1207,7 +1207,16 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||
max_tables = max_items * len(tables) // total_items
|
||||
max_views = max_items * len(views) // total_items
|
||||
|
||||
dataset_tables = {table.name: table for table in database.tables}
|
||||
extra_dict_by_name = {
|
||||
table.name: table.extra_dict
|
||||
for table in (
|
||||
db.session.query(SqlaTable).filter(
|
||||
SqlaTable.name.in_( # # pylint: disable=no-member
|
||||
f"{table.schema}.{table.table}" for table in tables
|
||||
)
|
||||
)
|
||||
).all()
|
||||
}
|
||||
|
||||
table_options = [
|
||||
{
|
||||
|
@ -1216,9 +1225,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||
"label": get_datasource_label(tn),
|
||||
"title": get_datasource_label(tn),
|
||||
"type": "table",
|
||||
"extra": dataset_tables[f"{tn.schema}.{tn.table}"].extra_dict
|
||||
if (f"{tn.schema}.{tn.table}" in dataset_tables)
|
||||
else None,
|
||||
"extra": extra_dict_by_name.get(f"{tn.schema}.{tn.table}", None),
|
||||
}
|
||||
for tn in tables[:max_tables]
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue