mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat: Add BaseDAO improvements and test reorganization (#35018)
Co-authored-by: bito-code-review[bot] <188872107+bito-code-review[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import dateutil.parser
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
@@ -35,8 +35,18 @@ from superset.views.base import DatasourceFilter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Custom filterable fields for datasets
|
||||
DATASET_CUSTOM_FIELDS: dict[str, list[str]] = {}
|
||||
|
||||
|
||||
class DatasetDAO(BaseDAO[SqlaTable]):
|
||||
"""
|
||||
DAO for datasets. Supports filtering on model fields, hybrid properties, and custom
|
||||
fields:
|
||||
- tags: list of tags (eq, in_, like)
|
||||
- owner: user id (eq, in_)
|
||||
"""
|
||||
|
||||
base_filter = DatasourceFilter
|
||||
|
||||
@staticmethod
|
||||
@@ -351,6 +361,13 @@ class DatasetDAO(BaseDAO[SqlaTable]):
|
||||
.one_or_none()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_filterable_columns_and_operators(cls) -> Dict[str, List[str]]:
|
||||
filterable = super().get_filterable_columns_and_operators()
|
||||
# Add custom fields
|
||||
filterable.update(DATASET_CUSTOM_FIELDS)
|
||||
return filterable
|
||||
|
||||
|
||||
class DatasetColumnDAO(BaseDAO[TableColumn]):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user