mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
docs: link the SQL to REST API Translator from the joins guide (#53771)
## Problem Readers who know the SQL join they want have to work out the matching embedding syntax by hand. The joins and nesting guide never mentions the SQL to REST API Translator, which does that conversion, so readers don't find it. Related to [FDBKIN-7994](https://linear.app/supabase/issue/FDBKIN-7994/improve-documentation-and-tooling-for-postgrest-join-syntax) Closes [DOCS-1729](https://linear.app/supabase/issue/DOCS-1729) ## Solution In the "Join types and join modifiers" section of `/guides/database/joins-and-nesting`, a new paragraph in the section's intro points readers who think in SQL to the translator. The paragraph says that the translator turns a SQL `select` query into a Data API request and Supabase JavaScript client code, with SQL joins as embedded relations. It also says that not every query translates, and names the translator's join limits: it handles only left and inner joins that compare columns with `=`, and the request it returns works only when a foreign key links the two tables. The paragraph follows the intro's explanation of left joins and `!inner`, so the translator's left-and-inner limit builds on it, and readers see the shortcut before the syntax table and the example tabs. Existing text is unchanged. ## How to verify 1. On the docs preview, open `/docs/guides/database/joins-and-nesting` and go to "Join types and join modifiers". 2. After the paragraph that ends "use `!inner` on the embedded relation", a paragraph names the SQL to REST API Translator and says that it converts SQL joins into embedded relations and client code. 3. The link opens `/docs/guides/api/sql-to-rest`. 4. The paragraph says that some queries won't translate. ## Checks Ran `pnpm turbo run typecheck --filter='...[origin/master]'`, `pnpm turbo run lint --filter='[origin/master]'`, and Prettier on the changed file. All pass. Skipped the docs tests, because they need Docker. Checked the facts against `apps/docs/content/guides/api/sql-to-rest.mdx` (the subset note), the translator component in `packages/ui-patterns/src/SqlToRest/` (cURL, HTTP, and JavaScript outputs), and the join handling in `@supabase/sql-to-rest` 0.1.6: it throws on join types other than inner and left and on join conditions other than `=`, and it does not check for a foreign key. ## Second reader First read: ready, no blockers, three nits. All three applied: the paragraph moved after the syntax table, two sentences merged, and the join limits named. Second read: one blocker. The join-limit sentence had the Data API as its subject, but the foreign key limit belongs to the translator, and the Data API also supports computed relationships. Fixed by making the translator the subject. Third read, after the first sentence was split in two: one blocker. The translator doesn't check foreign keys, so a join without one still translates, and the request then fails. Fixed: the sentence now says the translator handles only left and inner joins that compare columns with `=`, and that the request works only when a foreign key links the two tables. Nits left as they are: the translator outputs joins as flattened spread embeddings (`...relation(...)`), which this page doesn't explain; "client code" could read "supabase-js code". Fourth read, after the join-limits sentence was split in two: ready, no blockers. Nit left as it is: "For example" introduces translator limits after a sentence about Data API limits. Fifth read, after the paragraph moved into the section intro: ready, no blockers, and the placement matches the section's topic. Nits left as they are: when two foreign keys link the same tables, the translator's request is ambiguous and fails, because it never adds a foreign key hint (ambiguous foreign keys are out of scope here); and the last two sentences could form their own paragraph. Left as follow-ups outside the scope: the page intro says "data APIs" in lowercase, `guides/api/sql-to-api.mdx` doesn't link to the translator, and "We can get…" on the page uses _we_ for the reader. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) --------- Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com> Co-authored-by: Alexis Aguilar <98043211+alexisintech@users.noreply.github.com>
This commit is contained in:
1 parent
c3426aca1a
commit
8e50db7952
1 file changed
+2
@@ -232,6 +232,8 @@ By default, embedded relations use **left join** semantics from the parent table
|
||||
|
||||
To filter out parent rows that do not match the related table, use `!inner` on the embedded relation.
|
||||
|
||||
If you know the join you want in SQL, use the [SQL to REST API Translator](/docs/guides/api/sql-to-rest). It converts a SQL `select` query into the matching Data API request and Supabase JavaScript client code, with joins as embedded relations. The Data API supports only a subset of SQL, so some queries won't translate. For example, the translator handles only left and inner joins that compare columns with `=`. The request it returns works only when a foreign key links the two tables.
|
||||
|
||||
### What `:` and `!` mean in join syntax
|
||||
|
||||
| Syntax | Meaning | Example |
|
||||
|
||||
Reference in new issue
Block a user