Repository navigation
feat(postgrest): target another schema from a derived client - #1022
Merged
Merged
Conversation
Tr00d
marked this pull request as ready for review
December 2, 2026 07:32
This was referenced Dec 2, 2026
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.
Summary
A caller can derive a Postgrest client that targets another exposed schema for its table queries and function calls. The client it came from is unchanged.
Capability:
database.query.schema_selection, Schema Selection. This changes the status from partially implemented to implemented. There is no capability spec for it.Public API
Behavior
CallFunction,Rpc, and theUpdateandDeleteof models it returns or attaches.GETsends it asAccept-Profile.POST,PATCH,PUTandDELETEsend it asContent-Profile(Switching schemas).ArgumentNullExceptionbefore any request.HttpClientand proxy, enum serialization);GetHeaderscallback of the client it came from, so the umbrella client'sapikeyand session token keep reaching it.IPostgrestClient. The two clients' options, including theHeadersandQueryParamsdictionaries, are separate copies, and each keeps its comparer. NoHttpClientis created: the derived client sends through the same one.PGRST106. That becomes aPostgrestExceptionwithReason = FailureHint.Reason.InvalidSchema. All other failures are unchanged.Deviations from supabase-js
WithSchema, the .NET name for a derived copy, where supabase-js usesschema().ISupabaseClientgets no shortcut.supabase.Postgrest.WithSchema(...)reaches the same client.Tests
WithSchemaTestspersonalare read through the derived client; the original client still readspublic; an unexposed schema throwsInvalidSchemaWithSchemaRequestTestsAccept-Profileon a read,Content-ProfileonRpc; the original client keeps its schema and headers; theGetHeaderscallback is carried over;PGRST106maps toInvalidSchemaWithSchemaOptionsTestsDiff coverage: 100% (9 lines). Mutation: 3/3 killed on changed lines, 0 survivors. Stryker generates no mutant for the
?? throwguard, the target-typed object initializer or the dictionary copies; the tests cover them.Notes
ExplainRequestTests.ExplainAsync_ShouldNotReportMediaTypeNotAcceptable_GivenAnotherNotAcceptableAnswerused aPGRST106body as its example of an unrelated 406. That body now maps toInvalidSchema, so the test uses a 406 that carries no PostgREST code.PrepareRequestHeaders, an empty schema sends no profile header, so the request goes to the server's default schema; PostgREST is never asked about the empty name. This is the same asClientOptions.Schema = ""today.Count()sendsContent-ProfileonHEAD, so it counts the default schema. This affects the derived client andClientOptions.Schemaalike. fix(postgrest): count rows in the configured schema #1021 fixes it.ClientOptions.Schemadefaults to"public", which copies the service's default.