Skip to content

Commit 64557cb

Browse files
author
Вадим Козыревский
committed
fix after review
1 parent df2dabb commit 64557cb

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

examples/saga_sqlalchemy_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
logger = logging.getLogger(__name__)
4141

4242
# Database Configuration
43-
# Using SQLite for this example, but can be swapped for PostgreSQL/MySQL
44-
DB_URL = os.getenv("DATABASE_URL", "mysql+asyncmy://cqrs:cqrs@localhost:3307/test_cqrs")
43+
# Using SQLite for this example, but can be swapped for PostgreSQL/MySQL via DATABASE_URL
44+
DB_URL = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///./test.db")
4545

4646

4747
# ============================================================================

src/cqrs/saga/saga.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ async def __aiter__(
168168
run_cm = None
169169

170170
if run_cm is not None:
171-
async with run_cm as run:
172-
async for step_result in self._execute(run):
171+
try:
172+
async with run_cm as run:
173+
async for step_result in self._execute(run):
174+
yield step_result
175+
except NotImplementedError:
176+
async for step_result in self._execute(None):
173177
yield step_result
174178
else:
175179
async for step_result in self._execute(None):

src/cqrs/saga/storage/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ async def update_status(
238238
version=SagaExecutionModel.version + 1,
239239
),
240240
)
241-
if result.rowcount == 0:
241+
if result.rowcount == 0: # pyright: ignore[reportAttributeAccessIssue]
242242
raise SagaConcurrencyError(
243243
f"Saga {saga_id} does not exist or was modified concurrently",
244244
)

0 commit comments

Comments
 (0)