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
The bug is a mismatch between generated types and code behavior. The code below causes a TypeScript error despite functioning correctly.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Create tables using Supabase hosted with the following schemas:
create table
public.organizations (
id uuid not null default gen_random_uuid (),
created_at timestamp with time zone null default now(),
human_name text null,
slug text not null,
owner_user_id uuid not null default auth.uid (),
account_type text not null default 'pro'::text,
feature_flags jsonb null,
stripe_customer_id text null,
stripe_subscription_status text null,
stripe_seats_billed bigint null,
constraint organizations_pkey primary key (id, slug),
constraint organizations_id_key unique (id),
constraint organizations_stripe_customer_id_key unique (stripe_customer_id),
constraint organizations_owner_user_id_fkey foreign key (owner_user_id) references auth.users (id)
) tablespace pg_default;
create table
public.organization_members (
id bigint generated by default as identity,
created_at timestamp with time zone null default now(),
user_id uuid not null,
organization_id uuid not null,
scopes text[] null,
constraint organization_members_pkey primary key (id, user_id, organization_id),
constraint organization_members_user_id_key unique (user_id),
constraint organization_members_organization_id_fkey foreign key (organization_id) references organizations (id),
constraint organization_members_user_id_fkey foreign key (user_id) references auth.users (id)
) tablespace pg_default;
create index if not exists organization_members_user_id_idx on public.organization_members using btree (user_id) tablespace pg_default;
create index if not exists organization_members_organization_id_idx on public.organization_members using hash (organization_id) tablespace pg_default;
Use supabase CLI to generate types
Using the client in supabase.from('organizations').select('*, organization_members(count)') leads to type error, SelectQueryError, even though the behavior works as expected and a array with {count} is returned.
Expected behavior
I expect TypeScript to reflect this query with [{ count: number }] since the relation exists. The logic executes correctly and a count is returned, so the problem appears to be only with types. It is possible that because Supabase hosted puts the relations on separate lines from their corresponding column definitions that is throwing the schema builder off.
Screenshots
System information
OS: macOs
Browser (if applies) N/A
Version of supabase-js: 2.38.1
Version of Node.js: 18.18.2
Version of TypeScript: 5.2.2
Additional context
Also using SvelteKit, if that helps.
The text was updated successfully, but these errors were encountered:
Bug report
Describe the bug
The bug is a mismatch between generated types and code behavior. The code below causes a TypeScript error despite functioning correctly.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
supabase.from('organizations').select('*, organization_members(count)')
leads to type error, SelectQueryError, even though the behavior works as expected and a array with {count} is returned.Expected behavior
I expect TypeScript to reflect this query with [{ count: number }] since the relation exists. The logic executes correctly and a count is returned, so the problem appears to be only with types. It is possible that because Supabase hosted puts the relations on separate lines from their corresponding column definitions that is throwing the schema builder off.
Screenshots
System information
Additional context
Also using SvelteKit, if that helps.
The text was updated successfully, but these errors were encountered: