44from collections .abc import Awaitable , Callable
55from datetime import datetime , timedelta , timezone
66
7- from sqlalchemy import CursorResult
7+ from sqlalchemy import CursorResult , Row
88from sqlalchemy .ext .asyncio import AsyncSession
99from sqlmodel import col , delete , desc , func , or_ , select , text , update
1010
@@ -626,7 +626,7 @@ async def get_active_api_key_by_hash(self, key_hash: str) -> ApiKey | None:
626626 query = select (ApiKey ).where (
627627 ApiKey .key_hash == key_hash ,
628628 col (ApiKey .revoked_at ).is_ (None ),
629- or_ (col (ApiKey .expires_at ).is_ (None ), ApiKey .expires_at > now ),
629+ or_ (col (ApiKey .expires_at ).is_ (None ), col ( ApiKey .expires_at ) > now ),
630630 )
631631 result = await session .execute (query )
632632 return result .scalar_one_or_none ()
@@ -638,7 +638,7 @@ async def touch_api_key(self, key_id: str) -> None:
638638 async with session .begin ():
639639 await session .execute (
640640 update (ApiKey )
641- .where (ApiKey .key_id == key_id )
641+ .where (col ( ApiKey .key_id ) == key_id )
642642 .values (last_used_at = datetime .now (timezone .utc )),
643643 )
644644
@@ -649,7 +649,7 @@ async def revoke_api_key(self, key_id: str) -> bool:
649649 async with session .begin ():
650650 query = (
651651 update (ApiKey )
652- .where (ApiKey .key_id == key_id )
652+ .where (col ( ApiKey .key_id ) == key_id )
653653 .values (revoked_at = datetime .now (timezone .utc ))
654654 )
655655 result = T .cast (CursorResult , await session .execute (query ))
@@ -663,7 +663,7 @@ async def delete_api_key(self, key_id: str) -> bool:
663663 result = T .cast (
664664 CursorResult ,
665665 await session .execute (
666- delete (ApiKey ).where (ApiKey .key_id == key_id )
666+ delete (ApiKey ).where (col ( ApiKey .key_id ) == key_id )
667667 ),
668668 )
669669 return result .rowcount > 0
@@ -1457,7 +1457,7 @@ def _build_platform_sessions_query(
14571457 return query
14581458
14591459 @staticmethod
1460- def _rows_to_session_dicts (rows : list [ tuple ]) -> list [dict ]:
1460+ def _rows_to_session_dicts (rows : T . Sequence [ Row [ tuple ] ]) -> list [dict ]:
14611461 sessions_with_projects = []
14621462 for row in rows :
14631463 platform_session = row [0 ]
0 commit comments