mirror of https://github.com/apache/superset.git
forgotten query_datasources_by_name function (#2497)
* forgotten query_datasources_by_name function * use normal formats
This commit is contained in:
parent
37783d685f
commit
53990201bc
|
@ -66,3 +66,10 @@ class ConnectorRegistry(object):
|
|||
.filter_by(id=datasource_id)
|
||||
.one()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def query_datasources_by_name(
|
||||
cls, session, database, datasource_name, schema=None):
|
||||
datasource_class = ConnectorRegistry.sources[database.type]
|
||||
return datasource_class.query_datasources_by_name(
|
||||
session, database, datasource_name, schema=None)
|
||||
|
|
|
@ -1065,5 +1065,15 @@ class DruidDatasource(Model, BaseDatasource):
|
|||
filters = cond
|
||||
return filters
|
||||
|
||||
@classmethod
|
||||
def query_datasources_by_name(
|
||||
cls, session, database, datasource_name, schema=None):
|
||||
return (
|
||||
session.query(cls)
|
||||
.filter_by(cluster_name=database.id)
|
||||
.filter_by(datasource_name=datasource_name)
|
||||
.all()
|
||||
)
|
||||
|
||||
sa.event.listen(DruidDatasource, 'after_insert', set_perm)
|
||||
sa.event.listen(DruidDatasource, 'after_update', set_perm)
|
||||
|
|
|
@ -680,5 +680,17 @@ class SqlaTable(Model, BaseDatasource):
|
|||
db.session, i_datasource, lookup_database, lookup_sqlatable,
|
||||
import_time)
|
||||
|
||||
@classmethod
|
||||
def query_datasources_by_name(
|
||||
cls, session, database, datasource_name, schema=None):
|
||||
query = (
|
||||
session.query(cls)
|
||||
.filter_by(database_id=database.id)
|
||||
.filter_by(table_name=datasource_name)
|
||||
)
|
||||
if schema:
|
||||
query = query.filter_by(schema=schema)
|
||||
return query.all()
|
||||
|
||||
sa.event.listen(SqlaTable, 'after_insert', set_perm)
|
||||
sa.event.listen(SqlaTable, 'after_update', set_perm)
|
||||
|
|
Loading…
Reference in New Issue