Skip to content

Commit 963d6a5

Browse files
authored
Merge pull request #1299 from supabase/rc
feat: update postgrest-js with new query parser
2 parents ce1e2f0 + 029465b commit 963d6a5

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

package-lock.json

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@supabase/auth-js": "2.65.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.0",
4747
"@supabase/realtime-js": "2.10.7",
4848
"@supabase/storage-js": "2.7.1"
4949
},

src/SupabaseClient.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ export default class SupabaseClient<
221221
? Fn['Returns'][number]
222222
: never
223223
: never,
224-
Fn['Returns']
224+
Fn['Returns'],
225+
FnName,
226+
null
225227
> {
226228
return this.rest.rpc(fn, args, options)
227229
}

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

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)