diff --git a/apps/docs/spec/supabase_js_v2.yml b/apps/docs/spec/supabase_js_v2.yml index 80e9a6dbb4c..ae051e1225a 100644 --- a/apps/docs/spec/supabase_js_v2.yml +++ b/apps/docs/spec/supabase_js_v2.yml @@ -3223,6 +3223,69 @@ functions: "statusText": "OK" } ``` + - id: query-referenced-tables-with-spaces-in-their-names + name: Query referenced tables with spaces in their names + description: | + If your table name contains spaces, you must use double quotes in the `select` statement to reference the table. + code: | + ```js + const { data, error } = await supabase + .from('orchestal sections') + .select(` + name, + "musical instruments" ( + name + ) + `) + ``` + data: + sql: | + ```sql + create table + "orchestral sections" (id int8 primary key, name text); + create table + "musical instruments" ( + id int8 primary key, + section_id int8 not null references "orchestral sections", + name text + ); + + insert into + "orchestral sections" (id, name) + values + (1, 'strings'), + (2, 'woodwinds'); + insert into + "musical instruments" (id, section_id, name) + values + (1, 2, 'flute'), + (2, 1, 'violin'); + ``` + response: | + ```json + { + "data": [ + { + "name": "strings", + "musical instruments": [ + { + "name": "violin" + } + ] + }, + { + "name": "woodwinds", + "musical instruments": [ + { + "name": "flute" + } + ] + } + ], + "status": 200, + "statusText": "OK" + } + ``` - id: query-referenced-tables-through-a-join-table name: Query referenced tables through a join table code: |