Open mitjans opened 1 year ago
Any update on this @soedirgo ?
I would love to help, but I'm not that good with Typescript types.
I believe this has been fixed, you need to use a db-url to generate the types locally for now https://github.com/supabase/postgrest-js/pull/426
@imownbey I created this issue after adding a comment to that PR, so that it doesn't get lost in closed PR
Oh woops! My bad
Any update on this @soedirgo ?
This is actually a pretty gnarly issue because postgrest returns the child object not wrapped in an array but typescript now thinks it is in an array. This makes runtime errors very easy to run into and it hard to trust the typescript types.
This appears to still be an issue, as reported also in https://github.com/supabase/postgrest-js/issues/471, and https://github.com/supabase/postgrest-js/issues/408. I tried the workarounds in the second link, but with no luck. I agree this is an annoying issue, and makes the TS types hard to trust. It's also not clear to me if this issue is getting any attention from the Supabase team or not..
Running into this too. It's very annoying :(
Bug report
Describe the bug
I have a problem with one-to-one relationships. I have 3 tables:
Here are the SQL definitions extracted from Supabase (simplified columns):
problems
tableproblem_stats
tableproblem_votes
tableSo the relations are as follows:
problems
andproblem_stats
problems
andproblem_votes
This is the query:
This is the query response:
Here are the typescript types:
problem_stats
is represented as an array (although the response is an object because of the one-to-one relationship).problem_votes
is correctly represented as an array.I've noticed that when I select from
problem_stats
(instead ofproblems
) the type is inferred correctly (one-to-one).Now it has type:
Now it correctly represents the problems value as an object (one-to-one).