Closed jdgamble555 closed 4 weeks ago
facing the same issue, but changing the type of id
of users
table from uuid
to text
works for me.
is there a way to have the inner join query work for uuid
?
Hey @jdgamble555, the right query for this is:
await supabase.from('posts').select('*, user:users!inner(*)');
This should make user
non-nullable in the response type.
Querying embedded tables through columns (user:user_id(*)
) and using fkey columns as hints (user:users!user_id(*)
) currently has no typings support in the client lib, which explains why you're not getting the response types you expected.
@zineanteoh let me know if that works for you too! We have an example on our docs here but we might need to make it more front and center.
@soedirgo - Thanks, that solved the problem!
The docs show how to query, but as you can see above there is more than one way to query the results. Any query that works should also have correct typing. This would definitely stream line GH issues on the subject and confusion on possible queries.
J
👍 thanks for the feedback - this should get better as we get stricter with the typings, e.g. showing a type error instead of falling back to {}
or T[]
.
Bug report
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
I made a simple repository. You can run
npx supabase start
, but it is not necessary. Just open the file in VS Code and see the problems.Here is the Test Types
Here is the Schema
Or if you want to manually test it:
Expected behavior
A clear and concise description of what you expected to happen.
I want to do an inner join and get the correct types.
What I want
Test 1 Returns
Test 2 Returns
Test 3 Returns
I really just need
test
to return the correct typing. It is clearly a required FK with only one option, so it shouldn't be null nor an array.System information
Additional context
I have looked at these related posts, but none quite state the same problem clearly:
J