Skip to content

chore: update generated types #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/db/00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ CREATE TABLE public.channels (
ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase
COMMENT ON COLUMN public.channels.data IS 'For unstructured data and prototyping.';

create table public.channel_details (
id bigint primary key references channels(id),
details text default null
);

-- MESSAGES
CREATE TABLE public.messages (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
Expand Down
5 changes: 4 additions & 1 deletion test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
if (error) {
throw new Error(error.message)
}
expectType<{ bar: Json; baz: string }>(data)
// getting this w/o the cast, not sure why:
// Parameter type Json is declared too wide for argument type Json
expectType<Json>(data.bar as Json)
expectType<string>(data.baz)
}

// rpc return type
Expand Down
47 changes: 42 additions & 5 deletions test/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Json = string | number | boolean | null | { [key: string]: Json } | Json[]
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]

export interface Database {
personal: {
Expand Down Expand Up @@ -45,6 +45,29 @@ export interface Database {
}
public: {
Tables: {
channel_details: {
Row: {
details: string | null
id: number
}
Insert: {
details?: string | null
id: number
}
Update: {
details?: string | null
id?: number
}
Relationships: [
{
foreignKeyName: 'channel_details_id_fkey'
columns: ['id']
isOneToOne: true
referencedRelation: 'channels'
referencedColumns: ['id']
}
]
}
channels: {
Row: {
data: Json | null
Expand Down Expand Up @@ -86,17 +109,29 @@ export interface Database {
username?: string
}
Relationships: [
{
foreignKeyName: 'messages_channel_id_fkey'
columns: ['channel_id']
referencedRelation: 'channels'
referencedColumns: ['id']
},
{
foreignKeyName: 'messages_username_fkey'
columns: ['username']
referencedRelation: 'users'
referencedColumns: ['username']
},
{
foreignKeyName: 'messages_channel_id_fkey'
columns: ['channel_id']
referencedRelation: 'channels'
referencedColumns: ['id']
foreignKeyName: 'messages_username_fkey'
columns: ['username']
referencedRelation: 'non_updatable_view'
referencedColumns: ['username']
},
{
foreignKeyName: 'messages_username_fkey'
columns: ['username']
referencedRelation: 'updatable_view'
referencedColumns: ['username']
}
]
}
Expand Down Expand Up @@ -148,6 +183,7 @@ export interface Database {
Row: {
username: string | null
}
Relationships: []
}
updatable_view: {
Row: {
Expand All @@ -162,6 +198,7 @@ export interface Database {
non_updatable_column?: never
username?: string | null
}
Relationships: []
}
}
Functions: {
Expand Down