diff --git a/backend/api/documents.py b/backend/api/documents.py index 2715444..10456c5 100644 --- a/backend/api/documents.py +++ b/backend/api/documents.py @@ -346,7 +346,7 @@ async def confirm_upload( " AND (used_bytes + :delta) <= limit_bytes " "RETURNING used_bytes, limit_bytes" ), - {"delta": size, "uid": str(doc.user_id)}, + {"delta": size, "uid": doc.user_id.hex}, ) row = result.fetchone() @@ -354,7 +354,7 @@ async def confirm_upload( # Quota exceeded — fetch current quota state for the 413 body quota_result = await session.execute( text("SELECT used_bytes, limit_bytes FROM quotas WHERE user_id = :uid"), - {"uid": str(doc.user_id)}, + {"uid": doc.user_id.hex}, ) q = quota_result.fetchone() # Delete the pending Document row and best-effort remove the MinIO object diff --git a/backend/services/storage.py b/backend/services/storage.py index f0844d4..70f15da 100644 --- a/backend/services/storage.py +++ b/backend/services/storage.py @@ -185,7 +185,7 @@ async def delete_document( "SET used_bytes = CASE WHEN used_bytes > :delta THEN used_bytes - :delta ELSE 0 END " "WHERE user_id = :uid" ), - {"delta": doc.size_bytes, "uid": str(doc.user_id)}, + {"delta": doc.size_bytes, "uid": doc.user_id.hex}, ) await session.delete(doc) diff --git a/backend/tests/test_quota.py b/backend/tests/test_quota.py index 85597d7..979be22 100644 --- a/backend/tests/test_quota.py +++ b/backend/tests/test_quota.py @@ -192,7 +192,6 @@ async def test_quota_exceeded_response( assert detail["limit_bytes"] == 104_857_600, f"Unexpected limit_bytes: {detail}" -@pytest.mark.xfail(strict=False, reason="requires PostgreSQL for atomic UUID-typed quota SQL") async def test_delete_decrements_quota( async_client, db_session, auth_user, mock_minio_presigned, mock_minio_stat, monkeypatch ):