mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
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)
|
.filter_by(id=datasource_id)
|
||||||
.one()
|
.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
|
filters = cond
|
||||||
return filters
|
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_insert', set_perm)
|
||||||
sa.event.listen(DruidDatasource, 'after_update', 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,
|
db.session, i_datasource, lookup_database, lookup_sqlatable,
|
||||||
import_time)
|
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_insert', set_perm)
|
||||||
sa.event.listen(SqlaTable, 'after_update', set_perm)
|
sa.event.listen(SqlaTable, 'after_update', set_perm)
|
||||||
|
Loading…
Reference in New Issue
Block a user