Skip to content

Commit 2e7c776

Browse files
feat: sqlalchemy repository error if rowcount is not found
1 parent 4962d2a commit 2e7c776

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/common/infrastructure/base_sqlalchemy_repository.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,12 @@ def _raise_not_deleted(self) -> t.NoReturn:
221221
def _get_row_count(self, result: sa.Result) -> int:
222222
# NOTE: in runtime, the Result is a CursorResult which has this prop
223223
# but the type stubs do not reflect this
224-
return t.cast(sa.CursorResult[t.Any], result).rowcount
224+
match result:
225+
case sa.CursorResult(rowcount=row_count):
226+
return row_count
227+
case _:
228+
msg = (
229+
"Fatal: could not get row count from result. "
230+
"This could indicate a breaking change with sqlalchemy."
231+
)
232+
raise repository_errors.RepositoryError(msg)

0 commit comments

Comments
 (0)