Skip to content

Commit

Permalink
Revert "refactor: sql lab command: separate concerns into different m…
Browse files Browse the repository at this point in the history
…odules (apache#16917)"

This reverts commit 0d0c759.
  • Loading branch information
mistercrunch committed Oct 16, 2021
1 parent 9e6d5fc commit a540f15
Show file tree
Hide file tree
Showing 15 changed files with 285 additions and 660 deletions.
1 change: 0 additions & 1 deletion superset/charts/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=arguments-renamed
import logging
from typing import List, Optional, TYPE_CHECKING

Expand Down
35 changes: 0 additions & 35 deletions superset/dao/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=isinstance-second-argument-not-valid-type
from typing import Any, Dict, List, Optional, Type

from flask_appbuilder.models.filters import BaseFilter
Expand Down Expand Up @@ -90,19 +89,6 @@ def find_all(cls) -> List[Model]:
).apply(query, None)
return query.all()

@classmethod
def find_one_or_none(cls, **filter_by: Any) -> Optional[Model]:
"""
Get the first that fit the `base_filter`
"""
query = db.session.query(cls.model_cls)
if cls.base_filter:
data_model = SQLAInterface(cls.model_cls, db.session)
query = cls.base_filter( # pylint: disable=not-callable
"id", data_model
).apply(query, None)
return query.filter_by(**filter_by).one_or_none()

@classmethod
def create(cls, properties: Dict[str, Any], commit: bool = True) -> Model:
"""
Expand All @@ -123,27 +109,6 @@ def create(cls, properties: Dict[str, Any], commit: bool = True) -> Model:
raise DAOCreateFailedError(exception=ex) from ex
return model

@classmethod
def save(cls, instance_model: Model, commit: bool = True) -> Model:
"""
Generic for saving models
:raises: DAOCreateFailedError
"""
if cls.model_cls is None:
raise DAOConfigError()
if not isinstance(instance_model, cls.model_cls):
raise DAOCreateFailedError(
"the instance model is not a type of the model class"
)
try:
db.session.add(instance_model)
if commit:
db.session.commit()
except SQLAlchemyError as ex: # pragma: no cover
db.session.rollback()
raise DAOCreateFailedError(exception=ex) from ex
return instance_model

@classmethod
def update(
cls, model: Model, properties: Dict[str, Any], commit: bool = True
Expand Down
2 changes: 1 addition & 1 deletion superset/datasets/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def validate_metrics_uniqueness(dataset_id: int, metrics_names: List[str]) -> bo
return len(dataset_query) == 0

@classmethod
def update(
def update( # pylint: disable=arguments-differ
cls, model: SqlaTable, properties: Dict[str, Any], commit: bool = True
) -> Optional[SqlaTable]:
"""
Expand Down
3 changes: 1 addition & 2 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=line-too-long
"""A collection of ORM sqlalchemy models for Superset"""
import enum
import json
Expand Down Expand Up @@ -254,7 +253,7 @@ def parameters(self) -> Dict[str, Any]:
@property
def parameters_schema(self) -> Dict[str, Any]:
try:
parameters_schema = self.db_engine_spec.parameters_json_schema() # type: ignore
parameters_schema = self.db_engine_spec.parameters_json_schema() # type: ignore # pylint: disable=line-too-long
except Exception: # pylint: disable=broad-except
parameters_schema = {}
return parameters_schema
Expand Down
Loading

0 comments on commit a540f15

Please sign in to comment.