Skip to content

Commit 56c39a5

Browse files
authored
Merge pull request #490 from supabase/chore/update-generated-types
chore: update generated types
2 parents 5e7dbdc + f0ec2e9 commit 56c39a5

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

test/db/00-schema.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ CREATE TABLE public.channels (
2525
ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase
2626
COMMENT ON COLUMN public.channels.data IS 'For unstructured data and prototyping.';
2727

28+
create table public.channel_details (
29+
id bigint primary key references channels(id),
30+
details text default null
31+
);
32+
2833
-- MESSAGES
2934
CREATE TABLE public.messages (
3035
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,

test/index.test-d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
6262
if (error) {
6363
throw new Error(error.message)
6464
}
65-
expectType<{ bar: Json; baz: string }>(data)
65+
// getting this w/o the cast, not sure why:
66+
// Parameter type Json is declared too wide for argument type Json
67+
expectType<Json>(data.bar as Json)
68+
expectType<string>(data.baz)
6669
}
6770

6871
// rpc return type

test/types.ts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type Json = string | number | boolean | null | { [key: string]: Json } | Json[]
1+
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]
22

33
export interface Database {
44
personal: {
@@ -45,6 +45,29 @@ export interface Database {
4545
}
4646
public: {
4747
Tables: {
48+
channel_details: {
49+
Row: {
50+
details: string | null
51+
id: number
52+
}
53+
Insert: {
54+
details?: string | null
55+
id: number
56+
}
57+
Update: {
58+
details?: string | null
59+
id?: number
60+
}
61+
Relationships: [
62+
{
63+
foreignKeyName: 'channel_details_id_fkey'
64+
columns: ['id']
65+
isOneToOne: true
66+
referencedRelation: 'channels'
67+
referencedColumns: ['id']
68+
}
69+
]
70+
}
4871
channels: {
4972
Row: {
5073
data: Json | null
@@ -86,17 +109,29 @@ export interface Database {
86109
username?: string
87110
}
88111
Relationships: [
112+
{
113+
foreignKeyName: 'messages_channel_id_fkey'
114+
columns: ['channel_id']
115+
referencedRelation: 'channels'
116+
referencedColumns: ['id']
117+
},
89118
{
90119
foreignKeyName: 'messages_username_fkey'
91120
columns: ['username']
92121
referencedRelation: 'users'
93122
referencedColumns: ['username']
94123
},
95124
{
96-
foreignKeyName: 'messages_channel_id_fkey'
97-
columns: ['channel_id']
98-
referencedRelation: 'channels'
99-
referencedColumns: ['id']
125+
foreignKeyName: 'messages_username_fkey'
126+
columns: ['username']
127+
referencedRelation: 'non_updatable_view'
128+
referencedColumns: ['username']
129+
},
130+
{
131+
foreignKeyName: 'messages_username_fkey'
132+
columns: ['username']
133+
referencedRelation: 'updatable_view'
134+
referencedColumns: ['username']
100135
}
101136
]
102137
}
@@ -148,6 +183,7 @@ export interface Database {
148183
Row: {
149184
username: string | null
150185
}
186+
Relationships: []
151187
}
152188
updatable_view: {
153189
Row: {
@@ -162,6 +198,7 @@ export interface Database {
162198
non_updatable_column?: never
163199
username?: string | null
164200
}
201+
Relationships: []
165202
}
166203
}
167204
Functions: {

0 commit comments

Comments
 (0)