mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-16 04:02:55 -06:00
fix: introduce PreciseTimestamp to fix mysql datetime precision issue.
Copybara import of the project: -- c62a0a6da4317497b991f83d4d8561bdbe7292aa by Jacky W <wjx_colstu@hotmail.com>: -- 59c0606ac08ddb45ce469a4d1e1c6e515ef94df4 by Jacky W <wjx_colstu@hotmail.com>: fix: add cache_ok option to remove sa warning. -- 1922599075af935a63544762765d6f0e6224907a by Jacky W <wjx_colstu@hotmail.com>: chore: format code. COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1001 from Colstuwjx:fix/issue-480-precise-mysql-timestamp 50e764fb9646e326ad0204ff7adb2a5b65bf875a PiperOrigin-RevId: 764853016
This commit is contained in:
parent
a9dcc588ad
commit
841e10ae35
@ -92,6 +92,18 @@ class DynamicJSON(TypeDecorator):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class PreciseTimestamp(TypeDecorator):
|
||||||
|
"""Represents a timestamp precise to the microsecond."""
|
||||||
|
|
||||||
|
impl = DateTime
|
||||||
|
cache_ok = True
|
||||||
|
|
||||||
|
def load_dialect_impl(self, dialect):
|
||||||
|
if dialect.name == "mysql":
|
||||||
|
return dialect.type_descriptor(mysql.DATETIME(fsp=6))
|
||||||
|
return self.impl
|
||||||
|
|
||||||
|
|
||||||
class Base(DeclarativeBase):
|
class Base(DeclarativeBase):
|
||||||
"""Base class for database tables."""
|
"""Base class for database tables."""
|
||||||
|
|
||||||
@ -156,7 +168,9 @@ class StorageEvent(Base):
|
|||||||
branch: Mapped[str] = mapped_column(
|
branch: Mapped[str] = mapped_column(
|
||||||
String(DEFAULT_MAX_VARCHAR_LENGTH), nullable=True
|
String(DEFAULT_MAX_VARCHAR_LENGTH), nullable=True
|
||||||
)
|
)
|
||||||
timestamp: Mapped[DateTime] = mapped_column(DateTime(), default=func.now())
|
timestamp: Mapped[PreciseTimestamp] = mapped_column(
|
||||||
|
PreciseTimestamp, default=func.now()
|
||||||
|
)
|
||||||
content: Mapped[dict[str, Any]] = mapped_column(DynamicJSON, nullable=True)
|
content: Mapped[dict[str, Any]] = mapped_column(DynamicJSON, nullable=True)
|
||||||
actions: Mapped[MutableDict[str, Any]] = mapped_column(PickleType)
|
actions: Mapped[MutableDict[str, Any]] = mapped_column(PickleType)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user