diff --git a/fastcrud/crud/fast_crud.py b/fastcrud/crud/fast_crud.py index d3c876b..158e8e0 100644 --- a/fastcrud/crud/fast_crud.py +++ b/fastcrud/crud/fast_crud.py @@ -2222,6 +2222,8 @@ async def update( if return_columns: stmt = stmt.returning(*[column(name) for name in return_columns]) db_row = await db.execute(stmt) + if commit: + await db.commit() if allow_multiple: return self._as_multi_response( db_row, diff --git a/tests/sqlalchemy/crud/test_update.py b/tests/sqlalchemy/crud/test_update.py index c265370..b917f44 100644 --- a/tests/sqlalchemy/crud/test_update.py +++ b/tests/sqlalchemy/crud/test_update.py @@ -276,3 +276,7 @@ async def test_update_with_returning( ) assert updated_record == expected_result + + # Rollback the current transaction to see if the record was actually committed + await async_session.rollback() + assert await crud.count(async_session, name="Updated Name") == 1