Apologies beforehand if this is the wrong repo -- I wasn't sure if the root of the issue was in type generation (another repo?) or just in the translation to typescript.
We ran into a bug where the generated typescript types were nondeterminstic using supabase gen types typescript --local. There is an unordered list or a race condition that causes the order of types to change randomly. This is blocking our Github action to diff the generated types file.
The scenario that at least we repro'd is when it generates the types for a View that contains multiple FKs to the same table. In our case the table is self-referential but I don't know if that is a requirement. Here's a contrived example:
Let's say we have the following schema for a post (table), which can point to a parent post:
id (uuid)
body (text)
parent_post_id (FK to post id, nullable)
create table
public.post (
id uuid not null default gen_random_uuid (),
body text not null,
parent_post_id uuid null,
constraint post_pkey primary key (id),
constraint post_parent_post_id_fkey foreign key (parent_post_id) references post (id)
) tablespace pg_default;
Then let's say we create a view where I get all the posts and some info about the parent post, if it has one:
create view
public.my_view as
select
p.id as post_id,
p.body as post_body,
p.parent_post_id as post_parent_post_id,
parent_p.id as parent_post_id,
parent_p.body as parent_post_body
from
post p
left join post parent_p on p.parent_post_id = parent_p.id;
When we generate the types, the view types will be:
The issue is that the order of the Relationships objects can change for reasons we haven't identified. It's difficult to repro locally with on the same commit, but after some code changes that do not affect the schema(?), or consistently on Github actions, we'll hit this. The result is a diff like:
Bug report
Describe the bug
Apologies beforehand if this is the wrong repo -- I wasn't sure if the root of the issue was in type generation (another repo?) or just in the translation to typescript.
We ran into a bug where the generated typescript types were nondeterminstic using
supabase gen types typescript --local
. There is an unordered list or a race condition that causes the order of types to change randomly. This is blocking our Github action to diff the generated types file.The scenario that at least we repro'd is when it generates the types for a
View
that contains multiple FKs to the same table. In our case the table is self-referential but I don't know if that is a requirement. Here's a contrived example:post
(table), which can point to a parent post:id
(uuid)body
(text)parent_post_id
(FK to post id, nullable)Then let's say we create a view where I get all the posts and some info about the parent post, if it has one:
When we generate the types, the view types will be:
The issue is that the order of the
Relationships
objects can change for reasons we haven't identified. It's difficult to repro locally with on the same commit, but after some code changes that do not affect the schema(?), or consistently on Github actions, we'll hit this. The result is a diff like:Here's our Github action:
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Relationships
of the View types can change.Expected behavior
The ordering of the
Relationships
of the View types is consistent.System information
Additional context