Skip to content

Commit faa4f77

Browse files
authored
Merge pull request supabase#1330 from supabase/rc
feat: reland query parser changes
2 parents 322129c + d76c7b3 commit faa4f77

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ First of all, you need to install the library:
1111
npm install @supabase/supabase-js
1212
```
1313

14+
1415
Then you're able to import the library and establish the connection with the database:
1516

1617
```js

Diff for: package-lock.json

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@supabase/auth-js": "2.67.1",
4444
"@supabase/functions-js": "2.4.3",
4545
"@supabase/node-fetch": "2.6.15",
46-
"@supabase/postgrest-js": "1.16.3",
46+
"@supabase/postgrest-js": "1.17.7",
4747
"@supabase/realtime-js": "2.11.2",
4848
"@supabase/storage-js": "2.7.1"
4949
},

Diff for: src/SupabaseClient.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export default class SupabaseClient<
224224
? Fn['Returns'][number]
225225
: never
226226
: never,
227-
Fn['Returns']
227+
Fn['Returns'],
228+
FnName,
229+
null
228230
> {
229231
return this.rest.rpc(fn, args, options)
230232
}

Diff for: src/lib/types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,26 @@ export type SupabaseClientOptions<SchemaName> = {
8080
accessToken?: () => Promise<string>
8181
}
8282

83+
export type GenericRelationship = {
84+
foreignKeyName: string
85+
columns: string[]
86+
isOneToOne?: boolean
87+
referencedRelation: string
88+
referencedColumns: string[]
89+
}
90+
8391
export type GenericTable = {
8492
Row: Record<string, unknown>
8593
Insert: Record<string, unknown>
8694
Update: Record<string, unknown>
95+
Relationships: GenericRelationship[]
8796
}
8897

8998
export type GenericUpdatableView = GenericTable
9099

91100
export type GenericNonUpdatableView = {
92101
Row: Record<string, unknown>
102+
Relationships: GenericRelationship[]
93103
}
94104

95105
export type GenericView = GenericUpdatableView | GenericNonUpdatableView

Diff for: test/index.test-d.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const supabase = createClient<Database>(URL, KEY)
8484
if (error) {
8585
throw new Error(error.message)
8686
}
87-
expectType<Database['public']['Tables']['users']['Row'] | null>(message.user)
87+
expectType<Database['public']['Tables']['users']['Row']>(message.user)
8888
}
8989

9090
// one-to-many relationship
@@ -99,8 +99,11 @@ const supabase = createClient<Database>(URL, KEY)
9999
// referencing missing column
100100
{
101101
type SelectQueryError<Message extends string> = { error: true } & Message
102+
102103
const res = await supabase.from('users').select('username, dat')
103-
expectType<PostgrestSingleResponse<SelectQueryError<`Referencing missing column \`dat\``>[]>>(res)
104+
expectType<
105+
PostgrestSingleResponse<SelectQueryError<"column 'dat' does not exist on 'users'.">[]>
106+
>(res)
104107
}
105108

106109
// one-to-one relationship

0 commit comments

Comments
 (0)