Skip to content

fix(supabase): subscribe to changes in the table's schema - #1035

Merged
Tr00d merged 1 commit into
masterfrom
fix/supabase-realtime-table-schema
Dec 2, 2026
Merged

Tr00d merged 1 commit into
masterfrom
fix/supabase-realtime-table-schema

Conversation

@Tr00d

@Tr00d Tr00d commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

client.From<T>().On(...) listened to changes in public whatever the table's schema, so a table outside public ([Table(Schema = ...)], a client from WithSchema, or SupabaseOptions.Schema) was subscribed to the wrong topic and Realtime refused the join. The table now listens in the schema its requests target, which a table also reports through a new IPostgrestTable<TModel>.Schema.

Public API

// IPostgrestTable<TModel>, Table<TModel>
string Schema { get; }

// SupabaseTable<TModel>: listens in Schema
public SupabaseTable(IPostgrestClient postgrestClient, IRealtimeClient<RealtimeSocket, RealtimeChannel> realtimeClient);
[Table("users", Schema = "personal")]
public class PersonalUser : BaseModel { ... }

var table = client.From<PersonalUser>();   // table.Schema == "personal"
await table.On(ListenType.Inserts, (_, change) => { ... });   // realtime:personal:users

Behavior

  • IPostgrestTable<TModel>.Schema is the schema every request on the table targets: the schema of a client from WithSchema, otherwise TableAttribute.Schema, otherwise ClientOptions.Schema (feat(postgrest): query a table in the schema its model declares #1030).
  • SupabaseTable.On opens realtime:{Schema}:{table}. Client.From<T>() and StatelessClient.From<T>() build the table with the new constructor; the stateless one previously passed SupabaseOptions.Schema, which ignored a model's own schema.
  • The existing constructor SupabaseTable(postgrestClient, realtimeClient, string schema = "public") keeps its meaning for a caller that passes a schema: listen there. A caller that passed two arguments binds to the new constructor once recompiled; binaries built against the old one keep public until then.

Deviations from supabase-js

None in behavior: supabase-js subscribes to changes per channel, with the schema the caller names. The model-typed From<T>().On is C#-only.

Tests

Tier Class Pins
E2E TableChangesTests The composed client receives an insert into personal.users through From<PersonalUser>().On
Unit TableChangesChannelTests The channel schema for a table's own schema, a WithSchema client, the client schema and an explicit schema; both From paths build a table in its own schema
Unit ResolvedSchemaTests (Postgrest) Schema for each precedence case

Before the fix, the E2E test failed with Realtime refusing realtime:public:users ("Unable to subscribe to changes with given parameters … schema: public, table: users"), and three of the unit tests failed on the channel schema; Schema did not exist on IPostgrestTable.

Diff coverage: 100% (Postgrest 1 line, Supabase 4 lines). Mutation: Postgrest's changed line has no mutant; Supabase 2 killed of 2 tested on changed lines, 0 survivors.

Notes

  • supabase/migrations/1751173800_realtime_personal_users.sql adds personal.users to the supabase_realtime publication with full replica identity.
  • The change spans two packages that release together. The squashed commit is a fix, while the new members are features, so the release notes take both entries from the override below.

BEGIN_COMMIT_OVERRIDE
feat(postgrest): report the schema a table's requests target
fix(supabase): subscribe to changes in the table's schema
END_COMMIT_OVERRIDE

@Tr00d
Tr00d marked this pull request as ready for review December 2, 2026 10:44
@Tr00d
Tr00d merged commit 6075bf4 into master Dec 2, 2026
11 checks passed
@Tr00d
Tr00d deleted the fix/supabase-realtime-table-schema branch December 2, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant