3333 SessionFSReaddirWithTypesResult ,
3434 SessionFSReadFileResult ,
3535 SessionFSSqliteExistsResult ,
36- SessionFSSqliteQueryResult ,
3736 SessionFSSqliteQueryType ,
3837 SessionFSStatResult ,
3938)
39+ from .generated .rpc import (
40+ SessionFSSqliteQueryResult as _GeneratedSqliteQueryResult ,
41+ )
4042
4143
4244@dataclass
@@ -110,21 +112,37 @@ class MyProvider(SessionFsProvider, SessionFsSqliteProvider): ...
110112
111113 The adapter checks ``isinstance(provider, SessionFsSqliteProvider)`` at
112114 runtime to decide whether SQLite calls should be dispatched.
115+
116+ Providers are already session-scoped (created per session by the factory),
117+ so these methods do not take a ``session_id`` parameter.
113118 """
114119
115120 @abc .abstractmethod
116121 async def sqlite_query (
117122 self ,
118- session_id : str ,
119123 query : str ,
120124 query_type : SessionFSSqliteQueryType ,
121125 params : dict [str , float | str | None ] | None = None ,
122- ) -> SessionFSSqliteQueryResult :
126+ ) -> SessionFsSqliteQueryResult :
123127 """Execute a SQLite query against the provider's per-session database."""
124128
125129 @abc .abstractmethod
126- async def sqlite_exists (self , session_id : str ) -> bool :
127- """Return whether the provider has a SQLite database for *session_id*."""
130+ async def sqlite_exists (self ) -> bool :
131+ """Return whether the provider has a SQLite database for this session."""
132+
133+
134+ @dataclass
135+ class SessionFsSqliteQueryResult :
136+ """Result of a SQLite query execution.
137+
138+ Same shape as the generated RPC type but without the ``error`` field,
139+ since providers signal errors by raising exceptions.
140+ """
141+
142+ columns : list [str ]
143+ rows : list [dict [str , Any ]]
144+ rows_affected : int
145+ last_insert_rowid : float | None = None
128146
129147
130148def create_session_fs_adapter (provider : SessionFsProvider ) -> SessionFsHandler :
@@ -240,12 +258,12 @@ async def rename(self, params: Any) -> SessionFSError | None:
240258 except Exception as exc :
241259 return _to_session_fs_error (exc )
242260
243- async def sqlite_query (self , params : Any ) -> SessionFSSqliteQueryResult :
261+ async def sqlite_query (self , params : Any ) -> _GeneratedSqliteQueryResult :
244262 # SQLite methods intentionally skip toSessionFsError wrapping — FS errno
245263 # mapping (ENOENT) isn't meaningful for SQL errors and the JSON-RPC layer
246264 # already handles uncaught exceptions.
247265 if not isinstance (self ._p , SessionFsSqliteProvider ):
248- return SessionFSSqliteQueryResult (
266+ return _GeneratedSqliteQueryResult (
249267 columns = [],
250268 rows = [],
251269 rows_affected = 0 ,
@@ -254,18 +272,23 @@ async def sqlite_query(self, params: Any) -> SessionFSSqliteQueryResult:
254272 message = "SQLite is not supported by this SessionFs provider" ,
255273 ),
256274 )
257- return await self ._p .sqlite_query (
258- params .session_id ,
275+ result = await self ._p .sqlite_query (
259276 params .query ,
260277 params .query_type ,
261278 getattr (params , "params" , None ),
262279 )
280+ return _GeneratedSqliteQueryResult (
281+ columns = result .columns ,
282+ rows = result .rows ,
283+ rows_affected = result .rows_affected ,
284+ last_insert_rowid = result .last_insert_rowid ,
285+ )
263286
264287 async def sqlite_exists (self , params : Any ) -> SessionFSSqliteExistsResult :
265288 if not isinstance (self ._p , SessionFsSqliteProvider ):
266289 return SessionFSSqliteExistsResult .from_dict ({"exists" : False })
267290 try :
268- result = await self ._p .sqlite_exists (params . session_id ) # type: ignore[attr-defined]
291+ result = await self ._p .sqlite_exists ()
269292 return SessionFSSqliteExistsResult .from_dict ({"exists" : result })
270293 except Exception :
271294 return SessionFSSqliteExistsResult .from_dict ({"exists" : False })
0 commit comments