mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
chore(dao): Remove redundant convenience methods (#24967)
This commit is contained in:
parent
12f2b0f8e7
commit
0879b9215c
@ -301,31 +301,6 @@ class DatasetDAO(BaseDAO[SqlaTable]): # pylint: disable=too-many-public-methods
|
|||||||
.one_or_none()
|
.one_or_none()
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def update_column(
|
|
||||||
cls,
|
|
||||||
model: TableColumn,
|
|
||||||
properties: dict[str, Any],
|
|
||||||
commit: bool = True,
|
|
||||||
) -> TableColumn:
|
|
||||||
return DatasetColumnDAO.update(model, properties, commit=commit)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def create_column(
|
|
||||||
cls, properties: dict[str, Any], commit: bool = True
|
|
||||||
) -> TableColumn:
|
|
||||||
"""
|
|
||||||
Creates a Dataset model on the metadata DB
|
|
||||||
"""
|
|
||||||
return DatasetColumnDAO.create(attributes=properties, commit=commit)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def delete_column(cls, model: TableColumn, commit: bool = True) -> None:
|
|
||||||
"""
|
|
||||||
Deletes a Dataset column
|
|
||||||
"""
|
|
||||||
DatasetColumnDAO.delete(model, commit=commit)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_dataset_metric(cls, dataset_id: int, metric_id: int) -> SqlMetric | None:
|
def find_dataset_metric(cls, dataset_id: int, metric_id: int) -> SqlMetric | None:
|
||||||
# We want to apply base dataset filters
|
# We want to apply base dataset filters
|
||||||
@ -334,33 +309,6 @@ class DatasetDAO(BaseDAO[SqlaTable]): # pylint: disable=too-many-public-methods
|
|||||||
return None
|
return None
|
||||||
return db.session.query(SqlMetric).get(metric_id)
|
return db.session.query(SqlMetric).get(metric_id)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def delete_metric(cls, model: SqlMetric, commit: bool = True) -> None:
|
|
||||||
"""
|
|
||||||
Deletes a Dataset metric
|
|
||||||
"""
|
|
||||||
DatasetMetricDAO.delete(model, commit=commit)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def update_metric(
|
|
||||||
cls,
|
|
||||||
model: SqlMetric,
|
|
||||||
properties: dict[str, Any],
|
|
||||||
commit: bool = True,
|
|
||||||
) -> SqlMetric:
|
|
||||||
return DatasetMetricDAO.update(model, properties, commit=commit)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def create_metric(
|
|
||||||
cls,
|
|
||||||
properties: dict[str, Any],
|
|
||||||
commit: bool = True,
|
|
||||||
) -> SqlMetric:
|
|
||||||
"""
|
|
||||||
Creates a Dataset model on the metadata DB
|
|
||||||
"""
|
|
||||||
return DatasetMetricDAO.create(attributes=properties, commit=commit)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(
|
def delete(
|
||||||
cls,
|
cls,
|
||||||
|
@ -20,7 +20,7 @@ from typing import Optional
|
|||||||
from superset import security_manager
|
from superset import security_manager
|
||||||
from superset.commands.base import BaseCommand
|
from superset.commands.base import BaseCommand
|
||||||
from superset.connectors.sqla.models import TableColumn
|
from superset.connectors.sqla.models import TableColumn
|
||||||
from superset.daos.dataset import DatasetDAO
|
from superset.daos.dataset import DatasetColumnDAO, DatasetDAO
|
||||||
from superset.daos.exceptions import DAODeleteFailedError
|
from superset.daos.exceptions import DAODeleteFailedError
|
||||||
from superset.datasets.columns.commands.exceptions import (
|
from superset.datasets.columns.commands.exceptions import (
|
||||||
DatasetColumnDeleteFailedError,
|
DatasetColumnDeleteFailedError,
|
||||||
@ -43,7 +43,7 @@ class DeleteDatasetColumnCommand(BaseCommand):
|
|||||||
assert self._model
|
assert self._model
|
||||||
|
|
||||||
try:
|
try:
|
||||||
DatasetDAO.delete_column(self._model)
|
DatasetColumnDAO.delete(self._model)
|
||||||
except DAODeleteFailedError as ex:
|
except DAODeleteFailedError as ex:
|
||||||
logger.exception(ex.exception)
|
logger.exception(ex.exception)
|
||||||
raise DatasetColumnDeleteFailedError() from ex
|
raise DatasetColumnDeleteFailedError() from ex
|
||||||
|
@ -20,7 +20,7 @@ from typing import Optional
|
|||||||
from superset import security_manager
|
from superset import security_manager
|
||||||
from superset.commands.base import BaseCommand
|
from superset.commands.base import BaseCommand
|
||||||
from superset.connectors.sqla.models import SqlMetric
|
from superset.connectors.sqla.models import SqlMetric
|
||||||
from superset.daos.dataset import DatasetDAO
|
from superset.daos.dataset import DatasetDAO, DatasetMetricDAO
|
||||||
from superset.daos.exceptions import DAODeleteFailedError
|
from superset.daos.exceptions import DAODeleteFailedError
|
||||||
from superset.datasets.metrics.commands.exceptions import (
|
from superset.datasets.metrics.commands.exceptions import (
|
||||||
DatasetMetricDeleteFailedError,
|
DatasetMetricDeleteFailedError,
|
||||||
@ -43,7 +43,7 @@ class DeleteDatasetMetricCommand(BaseCommand):
|
|||||||
assert self._model
|
assert self._model
|
||||||
|
|
||||||
try:
|
try:
|
||||||
DatasetDAO.delete_metric(self._model)
|
DatasetMetricDAO.delete(self._model)
|
||||||
except DAODeleteFailedError as ex:
|
except DAODeleteFailedError as ex:
|
||||||
logger.exception(ex.exception)
|
logger.exception(ex.exception)
|
||||||
raise DatasetMetricDeleteFailedError() from ex
|
raise DatasetMetricDeleteFailedError() from ex
|
||||||
|
Loading…
Reference in New Issue
Block a user