Skip to content

Commit dd3a9b5

Browse files
authored
docs(supabase-js): add example to clarify how to fetch data with spaces in table name (supabase#33443)
* docs: add supabase-js example with spaces in table names * update copy and example
1 parent 517039f commit dd3a9b5

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

apps/docs/spec/supabase_js_v2.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,6 +3223,69 @@ functions:
32233223
"statusText": "OK"
32243224
}
32253225
```
3226+
- id: query-referenced-tables-with-spaces-in-their-names
3227+
name: Query referenced tables with spaces in their names
3228+
description: |
3229+
If your table name contains spaces, you must use double quotes in the `select` statement to reference the table.
3230+
code: |
3231+
```js
3232+
const { data, error } = await supabase
3233+
.from('orchestal sections')
3234+
.select(`
3235+
name,
3236+
"musical instruments" (
3237+
name
3238+
)
3239+
`)
3240+
```
3241+
data:
3242+
sql: |
3243+
```sql
3244+
create table
3245+
"orchestral sections" (id int8 primary key, name text);
3246+
create table
3247+
"musical instruments" (
3248+
id int8 primary key,
3249+
section_id int8 not null references "orchestral sections",
3250+
name text
3251+
);
3252+
3253+
insert into
3254+
"orchestral sections" (id, name)
3255+
values
3256+
(1, 'strings'),
3257+
(2, 'woodwinds');
3258+
insert into
3259+
"musical instruments" (id, section_id, name)
3260+
values
3261+
(1, 2, 'flute'),
3262+
(2, 1, 'violin');
3263+
```
3264+
response: |
3265+
```json
3266+
{
3267+
"data": [
3268+
{
3269+
"name": "strings",
3270+
"musical instruments": [
3271+
{
3272+
"name": "violin"
3273+
}
3274+
]
3275+
},
3276+
{
3277+
"name": "woodwinds",
3278+
"musical instruments": [
3279+
{
3280+
"name": "flute"
3281+
}
3282+
]
3283+
}
3284+
],
3285+
"status": 200,
3286+
"statusText": "OK"
3287+
}
3288+
```
32263289
- id: query-referenced-tables-through-a-join-table
32273290
name: Query referenced tables through a join table
32283291
code: |

0 commit comments

Comments
 (0)