fix(postgrest): throw on multi-row Single() result instead of returning null - #346
Open
fresh55 wants to merge 1 commit into
Open
fix(postgrest): throw on multi-row Single() result instead of returning null#346fresh55 wants to merge 1 commit into
fresh55 wants to merge 1 commit into
Conversation
fresh55
force-pushed
the
fix/postgrest-single-multirow-406
branch
from
August 12, 2026 21:10
cfe6dbe to
d599508
Compare
…ng null Single() asked PostgREST for a single object (Accept: application/vnd.pgrst.object+json) and swallowed the resulting 406 whenever the query didn't match exactly one row, so an under-constrained query that matched several rows was indistinguishable from "not found". Fetch a plain list instead and enforce cardinality client-side, as postgrest-js's maybeSingle() does: zero rows still returns null, more than one row now throws. CoercionTests' round-trip test is now scoped to the seeded row. Its unfiltered Single() was relying on the swallowed 406 whenever sibling tests had inserted extra kitchen_sink rows. Closes supabase-community#300
fresh55
force-pushed
the
fix/postgrest-single-multirow-406
branch
from
August 18, 2026 09:00
d599508 to
371a62a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single()asked PostgREST for a single object (Accept: application/vnd.pgrst.object+json) and swallowed the resulting 406 whenever the query didn't match exactly one row, so an under-constrained query that matched several rows was indistinguishable from "not found" (#300).This fetches a plain list instead and enforces cardinality client-side, the way postgrest-js's
maybeSingle()has done since supabase/postgrest-js#361: zero rows still returns null, more than one row now throws aPostgrestException. That also drops the dependency on PostgREST's error wording.CoercionTests' round-trip test is now scoped to the seeded row. Its unfilteredSingle()was relying on the swallowed 406 whenever sibling tests had inserted extrakitchen_sinkrows.Versioning
Callers that treated null as "not found" on a query that actually matched several rows now get a
PostgrestExceptioninstead. I've left the!off the subject since the old return value was never intentional, and lockstep versioning would major-bump all seven packages for it.Closes #300