Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/google/adk/sessions/database_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ def process_result_value(self, value, dialect: Dialect):
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):
"""Base class for database tables."""

Expand Down Expand Up @@ -156,7 +168,9 @@ class StorageEvent(Base):
branch: Mapped[str] = mapped_column(
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)
actions: Mapped[MutableDict[str, Any]] = mapped_column(PickleType)

Expand Down
Loading