mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
chore(db_engine_specs): clean up column spec logic and add tests (#22871)
This commit is contained in:
@@ -19,11 +19,11 @@ from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Pattern, Set, Tuple, TYPE_CHECKING
|
||||
|
||||
from flask_babel import gettext as __
|
||||
from sqlalchemy import types
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.errors import SupersetErrorType
|
||||
from superset.utils import core as utils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# prevent circular imports
|
||||
@@ -76,12 +76,8 @@ class SqliteEngineSpec(BaseEngineSpec):
|
||||
def convert_dttm(
|
||||
cls, target_type: str, dttm: datetime, db_extra: Optional[Dict[str, Any]] = None
|
||||
) -> Optional[str]:
|
||||
tt = target_type.upper()
|
||||
if tt in (
|
||||
utils.TemporalType.TEXT,
|
||||
utils.TemporalType.DATETIME,
|
||||
utils.TemporalType.TIMESTAMP,
|
||||
):
|
||||
sqla_type = cls.get_sqla_column_type(target_type)
|
||||
if isinstance(sqla_type, (types.String, types.DateTime)):
|
||||
return f"""'{dttm.isoformat(sep=" ", timespec="seconds")}'"""
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user