supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
964 stars 128 forks source link

Handle column name embed #451

Open wyozi opened 11 months ago

wyozi commented 11 months ago

What kind of change does this PR introduce?

Handle column name as target. See column name section at https://postgrest.org/en/stable/references/api/resource_embedding.html#embedding-disambiguation

What is the new behavior?

When a many-to-one relationship from messages->users exists in form of user_id foreign-key in messages, this change allows using the following form to type-safely embed a user:

client.from("messages").select("user:user_id(name)")

This was previously only possible by using a relationship name as the target or by using a foreign key name as a hint

Additional context

fixes #450

wyozi commented 3 months ago

@steve-chavez this one is also rebased and improved