We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4962d2a commit 35da134Copy full SHA for 35da134
1 file changed
app/common/infrastructure/base_sqlalchemy_repository.py
@@ -221,4 +221,14 @@ def _raise_not_deleted(self) -> t.NoReturn:
221
def _get_row_count(self, result: sa.Result) -> int:
222
# NOTE: in runtime, the Result is a CursorResult which has this prop
223
# but the type stubs do not reflect this
224
- return t.cast(sa.CursorResult[t.Any], result).rowcount
+ match result:
225
+ case sa.CursorResult(rowcount=row_count):
226
+ return row_count
227
+ case _:
228
+ msg = (
229
+ "Can't get result row count: "
230
+ f"expected result to be a CursorResult, got {type(result)} instead. "
231
+ "This could indicate a breaking change with sqlalchemy, "
232
+ "review sqlalchemy repository implementation."
233
+ )
234
+ raise repository_errors.RepositoryError(msg)
0 commit comments