You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enabling strict-raw-types in supabase_lints (the strict-raw-types enablement work) surfaced that several builders erase their generic type parameter to dynamic. The non-breaking pass made those dynamic arguments explicit so the rule can be enabled, but it deliberately did not change behavior. This issue tracks the follow-up breaking change: actually threading a real row type parameter through the builders.
Problem
The PostgREST/Supabase builder classes are already generic, but the public entry points throw the type away:
// postgrest: from() erases the row typePostgrestQueryBuilder<void> from(String table) { ... }
// supabase: SupabaseQueryBuilder is hard-coded to dynamicclassSupabaseQueryBuilderextendsPostgrestQueryBuilder<dynamic> { ... }
// rpc builder is fully rawclassPostgrestRpcBuilderextendsRawPostgrestBuilder<dynamic, dynamic, dynamic> { ... }
// stream builder holds a dynamic query builderfinalPostgrestQueryBuilder<dynamic> _queryBuilder;
As a result there is no way for a caller to say "this table's rows are MyModel" (or even Map<String, dynamic>) and get typed results back. Everything degrades to dynamic, which is exactly what strict-raw-types warns about, and it means no compile-time safety on .select() / .single() / .stream() results.
Proposed change (breaking)
Thread a real type parameter through the builder chain so the row type flows from the entry point to the result, similar to how supabase-js types from/rpc:
PostgrestClient.from(String table) → from<T>(String table) (or a schema-typed variant), returning PostgrestQueryBuilder<T> instead of PostgrestQueryBuilder<void>.
SupabaseClient.from / SupabaseQueryBuilder carry T instead of being fixed to dynamic.
SupabaseStreamBuilder and PostgrestRpcBuilder carry the real type instead of dynamic.
Keep the idiomatic-Dart shape (no JS-mirrored surface); default T sensibly so the common untyped path stays ergonomic.
Why this is breaking
Changing from to from<T> and changing the fixed dynamic/void type arguments changes the public generic signatures.
Return types of chained calls change, so code relying on the current dynamic results may need explicit types or casts.
Any consumer extending SupabaseQueryBuilder / the builders sees a changed supertype arity.
Because of this it is scheduled for v3.
Related
Non-breaking prerequisite: enable strict-raw-types and make the existing dynamic explicit.
Background
Enabling
strict-raw-typesinsupabase_lints(the strict-raw-types enablement work) surfaced that several builders erase their generic type parameter todynamic. The non-breaking pass made thosedynamicarguments explicit so the rule can be enabled, but it deliberately did not change behavior. This issue tracks the follow-up breaking change: actually threading a real row type parameter through the builders.Problem
The PostgREST/Supabase builder classes are already generic, but the public entry points throw the type away:
As a result there is no way for a caller to say "this table's rows are
MyModel" (or evenMap<String, dynamic>) and get typed results back. Everything degrades todynamic, which is exactly whatstrict-raw-typeswarns about, and it means no compile-time safety on.select()/.single()/.stream()results.Proposed change (breaking)
Thread a real type parameter through the builder chain so the row type flows from the entry point to the result, similar to how
supabase-jstypesfrom/rpc:PostgrestClient.from(String table)→from<T>(String table)(or a schema-typed variant), returningPostgrestQueryBuilder<T>instead ofPostgrestQueryBuilder<void>.SupabaseClient.from/SupabaseQueryBuildercarryTinstead of being fixed todynamic.SupabaseStreamBuilderandPostgrestRpcBuildercarry the real type instead ofdynamic.Tsensibly so the common untyped path stays ergonomic.Why this is breaking
fromtofrom<T>and changing the fixeddynamic/voidtype arguments changes the public generic signatures.dynamicresults may need explicit types or casts.SupabaseQueryBuilder/ the builders sees a changed supertype arity.Because of this it is scheduled for v3.
Related
strict-raw-typesand make the existingdynamicexplicit.