File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
src/ttt/infrastructure/adapters Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ async def game_with_game_location(
2020 join_condition = (TableUser .id == game_location_user_id ) & (
2121 TableUser .game_location_game_id == TableGame .id
2222 )
23- stmt = select (TableGame ).join (TableUser , join_condition )
23+ stmt = (
24+ select (TableGame ).join (TableUser , join_condition ).with_for_update ()
25+ )
2426
2527 table_game = await self ._session .scalar (stmt )
2628
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ async def contains_user_with_id(
1919 id_ : int ,
2020 / ,
2121 ) -> bool :
22- stmt = select (exists (1 ).where (TableUser .id == id_ ))
22+ stmt = select (exists (1 ).where (TableUser .id == id_ )). with_for_update ()
2323
2424 return bool (await self ._session .execute (stmt ))
2525
@@ -50,6 +50,7 @@ async def users_with_ids(
5050 return tuple (users )
5151
5252 async def user_with_id (self , id_ : int , / ) -> User | None :
53- table_user = await self ._session .get (TableUser , id_ )
53+ stmt = select (TableUser ).where (TableUser .id == id_ ).with_for_update ()
54+ table_user = await self ._session .scalar (stmt )
5455
5556 return None if table_user is None else table_user .entity ()
You can’t perform that action at this time.
0 commit comments