From 2836d6083e461a82e1d9f6636b761ed4f807b078 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Thu, 30 Jul 2026 02:48:21 +0200 Subject: [PATCH] fix: add async_session_maker alias in db/__init__.py for plugin imports --- app/core/db/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/core/db/__init__.py b/app/core/db/__init__.py index 1967a19..01604f3 100644 --- a/app/core/db/__init__.py +++ b/app/core/db/__init__.py @@ -86,6 +86,21 @@ def get_session_factory() -> async_sessionmaker[AsyncSession]: return _session_factory +# Backward-compat alias: code imports `async_session_maker` from app.core.db. +# Behaves like the session factory — calling it returns an AsyncSession. +# We use a wrapper class so `async with async_session_maker() as db:` works. +class _AsyncSessionMakerWrapper: + """Lazy proxy for the global async_sessionmaker.""" + def __call__(self) -> AsyncSession: + return get_session_factory()() + + def __getattr__(self, name: str) -> Any: + return getattr(get_session_factory(), name) + + +async_session_maker = _AsyncSessionMakerWrapper() + + async def get_db() -> AsyncGenerator[AsyncSession, None]: """FastAPI dependency: yield an async database session.""" factory = get_session_factory()