mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore: switching out ConnectorRegistry references for DatasourceDAO (#20380)
* rename and move dao file * Update dao.py * add cachekey * Update __init__.py * change reference in query context test * add utils ref * more ref changes * add helpers * add todo in dashboard.py * add cachekey * circular import error in dar.py * push rest of refs * fix linting * fix more linting * update enum * remove references for connector registry * big reafctor * take value * fix * test to see if removing value works * delete connectregistry * address concerns * address comments * fix merge conflicts * address concern II * address concern II * fix test Co-authored-by: Phillip Kelley-Dotson <pkelleydotson@yahoo.com>
This commit is contained in:
@@ -25,9 +25,10 @@ from superset.commands.exceptions import (
|
||||
OwnersNotFoundValidationError,
|
||||
RolesNotFoundValidationError,
|
||||
)
|
||||
from superset.connectors.connector_registry import ConnectorRegistry
|
||||
from superset.datasets.commands.exceptions import DatasetNotFoundError
|
||||
from superset.dao.exceptions import DatasourceNotFound
|
||||
from superset.datasource.dao import DatasourceDAO
|
||||
from superset.extensions import db, security_manager
|
||||
from superset.utils.core import DatasourceType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from superset.connectors.base.models import BaseDatasource
|
||||
@@ -79,8 +80,8 @@ def populate_roles(role_ids: Optional[List[int]] = None) -> List[Role]:
|
||||
|
||||
def get_datasource_by_id(datasource_id: int, datasource_type: str) -> BaseDatasource:
|
||||
try:
|
||||
return ConnectorRegistry.get_datasource(
|
||||
datasource_type, datasource_id, db.session
|
||||
return DatasourceDAO.get_datasource(
|
||||
db.session, DatasourceType(datasource_type), datasource_id
|
||||
)
|
||||
except DatasetNotFoundError as ex:
|
||||
except DatasourceNotFound as ex:
|
||||
raise DatasourceNotFoundValidationError() from ex
|
||||
|
||||
Reference in New Issue
Block a user