fix(postgrest): handle maybe_single zero-row responses correctly#1401
fix(postgrest): handle maybe_single zero-row responses correctly#1401AhmedAli58 wants to merge 1 commit intosupabase:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting Disabled knowledge base sources:
📒 Files selected for processing (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis pull request fixes a bug where Assessment against linked issues
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This would be a breaking change, so we won't be doing it for v2. I'll be fixing this in the next major version myself, you can follow it's development here #1370. |
Summary
Fixes #1207.
maybe_single()now treats zero-row responses returned as HTTP 204 (No Content) as an empty-success case and returnsSingleAPIResponse(data=None)instead of raisingAPIError.What changed
SyncMaybeSingleRequestBuilder.execute()andAsyncMaybeSingleRequestBuilder.execute()to treat 204/no-row outcomes asdata=None."The result contains 0 rows"error details[]path inmaybe_single()todata=None.Behavior guarantees
maybe_single()on zero rows: returns response object withdata=None.single()behavior is unchanged: zero-row error responses still raiseAPIError.Tests
Added regression coverage in both sync and async client tests:
test_maybe_single_returns_none_on_no_rows_204test_single_raises_on_no_rowsVerification
make ruffpasseduv run --package postgrest mypy src/postgrest testspasseduv run --package postgrest pytest src/postgrest/tests/_sync/test_client.py src/postgrest/tests/_async/test_client.py -vvpasseduv run --package postgrest pytest src/postgrest/tests -vv -k "not integration"passedNote:
make postgrest.testscould not run integration tests in this environment becausedockeris not installed (/bin/sh: docker: command not found).