Bug report
Describe the bug
When sorting grouped functions for schema generation, postgres-meta does not sort function definitions by SetofOptions, which leads to unstable schema generation.
To Reproduce
- Create multiple join functions that take different table type as arguments but return the same set of table row. In other words, define join functions for B -> A, C -> A, D -> A
- Run typegen
- dump database
- supabase db reset
- restore database
- typegen <- doesn't always change but also doesn't always stay the same
Expected behavior
schema generation should be deterministic and stable, regardless of function return type
Screenshots
System information
- OS: macOS or Linux
Browser (if applies) [e.g. chrome, safari]
Version of supabase-js: [e.g. 6.0.2]
- Version of Node.js: 22.14.0
- "supabase": "^2.54.11"
Additional context
The problem is this sort right here: https://github.com/supabase/postgres-meta/blob/master/src/server/templates/typescript.ts#L685
This line gives different loop results because sourceTable isn't part of the sort behavior above: https://github.com/supabase/postgres-meta/blob/master/src/server/templates/typescript.ts#L256
Bug report
Describe the bug
When sorting grouped functions for schema generation, postgres-meta does not sort function definitions by SetofOptions, which leads to unstable schema generation.
To Reproduce
Expected behavior
schema generation should be deterministic and stable, regardless of function return type
Screenshots
System information
Browser (if applies) [e.g. chrome, safari]Version of supabase-js: [e.g. 6.0.2]Additional context
The problem is this sort right here: https://github.com/supabase/postgres-meta/blob/master/src/server/templates/typescript.ts#L685
This line gives different loop results because sourceTable isn't part of the sort behavior above: https://github.com/supabase/postgres-meta/blob/master/src/server/templates/typescript.ts#L256