fix: wait_for_row_change raises and never detects changes under REPEATABLE READ (#327)

This commit is contained in:
d3vyce
2026-06-26 18:50:45 +02:00
committed by GitHub
parent 025f1907fd
commit 1e021005bc
2 changed files with 67 additions and 3 deletions
+7 -3
View File
@@ -57,7 +57,12 @@ async def wait_for_row_change(
)
```
"""
instance = await session.get(model, pk_value)
async def _reload() -> _M | None:
await session.rollback()
return await session.get(model, pk_value, populate_existing=True)
instance = await _reload()
if instance is None:
raise NotFoundError(f"{model.__name__} with pk={pk_value!r} not found")
@@ -79,8 +84,7 @@ async def wait_for_row_change(
f"with pk={pk_value!r} within {timeout}s"
)
session.expunge(instance)
instance = await session.get(model, pk_value)
instance = await _reload()
if instance is None:
raise NotFoundError(f"{model.__name__} with pk={pk_value!r} was deleted")