Skip to content

Commit

Permalink
fix: relationship types
Browse files Browse the repository at this point in the history
  • Loading branch information
psteinroe committed Jul 5, 2023
1 parent e0b388c commit 5e9b574
Show file tree
Hide file tree
Showing 23 changed files with 1,106 additions and 224 deletions.
8 changes: 8 additions & 0 deletions .changeset/soft-birds-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@supabase-cache-helpers/postgrest-react-query": patch
"@supabase-cache-helpers/postgrest-fetcher": patch
"@supabase-cache-helpers/postgrest-filter": patch
"@supabase-cache-helpers/postgrest-swr": patch
---

fix: relationship types
70 changes: 68 additions & 2 deletions examples/react-query/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Database {
tags: string[] | null
ticket_number: number | null
username: string | null
has_low_ticket_number: boolean | null
has_low_ticket_number: unknown | null
}
Insert: {
age_range?: unknown | null
Expand Down Expand Up @@ -75,6 +75,20 @@ export interface Database {
ticket_number?: number | null
username?: string | null
}
Relationships: [
{
foreignKeyName: "contact_continent_fkey"
columns: ["continent"]
referencedRelation: "continent"
referencedColumns: ["code"]
},
{
foreignKeyName: "contact_country_fkey"
columns: ["country"]
referencedRelation: "country"
referencedColumns: ["code"]
}
]
}
contact_note: {
Row: {
Expand All @@ -95,6 +109,14 @@ export interface Database {
id?: string
text?: string
}
Relationships: [
{
foreignKeyName: "contact_note_contact_id_fkey"
columns: ["contact_id"]
referencedRelation: "contact"
referencedColumns: ["id"]
}
]
}
continent: {
Row: {
Expand All @@ -109,6 +131,7 @@ export interface Database {
code?: string
name?: string | null
}
Relationships: []
}
country: {
Row: {
Expand All @@ -135,6 +158,14 @@ export interface Database {
name?: string
number?: string
}
Relationships: [
{
foreignKeyName: "country_continent_code_fkey"
columns: ["continent_code"]
referencedRelation: "continent"
referencedColumns: ["code"]
}
]
}
}
Views: {
Expand Down Expand Up @@ -191,6 +222,14 @@ export interface Database {
public?: boolean | null
updated_at?: string | null
}
Relationships: [
{
foreignKeyName: "buckets_owner_fkey"
columns: ["owner"]
referencedRelation: "users"
referencedColumns: ["id"]
}
]
}
migrations: {
Row: {
Expand All @@ -211,6 +250,7 @@ export interface Database {
id?: number
name?: string
}
Relationships: []
}
objects: {
Row: {
Expand All @@ -223,6 +263,7 @@ export interface Database {
owner: string | null
path_tokens: string[] | null
updated_at: string | null
version: string | null
}
Insert: {
bucket_id?: string | null
Expand All @@ -234,6 +275,7 @@ export interface Database {
owner?: string | null
path_tokens?: string[] | null
updated_at?: string | null
version?: string | null
}
Update: {
bucket_id?: string | null
Expand All @@ -245,13 +287,37 @@ export interface Database {
owner?: string | null
path_tokens?: string[] | null
updated_at?: string | null
version?: string | null
}
Relationships: [
{
foreignKeyName: "objects_bucketId_fkey"
columns: ["bucket_id"]
referencedRelation: "buckets"
referencedColumns: ["id"]
},
{
foreignKeyName: "objects_owner_fkey"
columns: ["owner"]
referencedRelation: "users"
referencedColumns: ["id"]
}
]
}
}
Views: {
[_ in never]: never
}
Functions: {
can_insert_object: {
Args: {
bucketid: string
name: string
owner: string
metadata: Json
}
Returns: undefined
}
extension: {
Args: {
name: string
Expand All @@ -268,7 +334,7 @@ export interface Database {
Args: {
name: string
}
Returns: string[]
Returns: unknown
}
get_size_by_bucket: {
Args: Record<PropertyKey, never>
Expand Down
70 changes: 68 additions & 2 deletions examples/swr/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Database {
tags: string[] | null
ticket_number: number | null
username: string | null
has_low_ticket_number: boolean | null
has_low_ticket_number: unknown | null
}
Insert: {
age_range?: unknown | null
Expand Down Expand Up @@ -75,6 +75,20 @@ export interface Database {
ticket_number?: number | null
username?: string | null
}
Relationships: [
{
foreignKeyName: "contact_continent_fkey"
columns: ["continent"]
referencedRelation: "continent"
referencedColumns: ["code"]
},
{
foreignKeyName: "contact_country_fkey"
columns: ["country"]
referencedRelation: "country"
referencedColumns: ["code"]
}
]
}
contact_note: {
Row: {
Expand All @@ -95,6 +109,14 @@ export interface Database {
id?: string
text?: string
}
Relationships: [
{
foreignKeyName: "contact_note_contact_id_fkey"
columns: ["contact_id"]
referencedRelation: "contact"
referencedColumns: ["id"]
}
]
}
continent: {
Row: {
Expand All @@ -109,6 +131,7 @@ export interface Database {
code?: string
name?: string | null
}
Relationships: []
}
country: {
Row: {
Expand All @@ -135,6 +158,14 @@ export interface Database {
name?: string
number?: string
}
Relationships: [
{
foreignKeyName: "country_continent_code_fkey"
columns: ["continent_code"]
referencedRelation: "continent"
referencedColumns: ["code"]
}
]
}
}
Views: {
Expand Down Expand Up @@ -191,6 +222,14 @@ export interface Database {
public?: boolean | null
updated_at?: string | null
}
Relationships: [
{
foreignKeyName: "buckets_owner_fkey"
columns: ["owner"]
referencedRelation: "users"
referencedColumns: ["id"]
}
]
}
migrations: {
Row: {
Expand All @@ -211,6 +250,7 @@ export interface Database {
id?: number
name?: string
}
Relationships: []
}
objects: {
Row: {
Expand All @@ -223,6 +263,7 @@ export interface Database {
owner: string | null
path_tokens: string[] | null
updated_at: string | null
version: string | null
}
Insert: {
bucket_id?: string | null
Expand All @@ -234,6 +275,7 @@ export interface Database {
owner?: string | null
path_tokens?: string[] | null
updated_at?: string | null
version?: string | null
}
Update: {
bucket_id?: string | null
Expand All @@ -245,13 +287,37 @@ export interface Database {
owner?: string | null
path_tokens?: string[] | null
updated_at?: string | null
version?: string | null
}
Relationships: [
{
foreignKeyName: "objects_bucketId_fkey"
columns: ["bucket_id"]
referencedRelation: "buckets"
referencedColumns: ["id"]
},
{
foreignKeyName: "objects_owner_fkey"
columns: ["owner"]
referencedRelation: "users"
referencedColumns: ["id"]
}
]
}
}
Views: {
[_ in never]: never
}
Functions: {
can_insert_object: {
Args: {
bucketid: string
name: string
owner: string
metadata: Json
}
Returns: undefined
}
extension: {
Args: {
name: string
Expand All @@ -268,7 +334,7 @@ export interface Database {
Args: {
name: string
}
Returns: string[]
Returns: unknown
}
get_size_by_bucket: {
Args: Record<PropertyKey, never>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test": "turbo run test --concurrency=1",
"format:write": "turbo run format:write",
"format:check": "turbo run format:check",
"typegen": "supabase gen types typescript --local > packages/postgrest-swr/__tests__/database.types.ts && supabase gen types typescript --local > packages/postgrest-filter/__tests__/database.types.ts && supabase gen types typescript --local > packages/postgrest-fetcher/__tests__/database.types.ts",
"typegen": "supabase gen types typescript --local > packages/postgrest-swr/__tests__/database.types.ts && supabase gen types typescript --local > packages/postgrest-filter/__tests__/database.types.ts && supabase gen types typescript --local > packages/postgrest-fetcher/__tests__/database.types.ts && supabase gen types typescript --local > examples/swr/types/database.ts && supabase gen types typescript --local > examples/react-query/types/database.ts",
"clear-branches": "git branch --merged | egrep -v \"(^\\*|main)\" | xargs git branch -d",
"merge-main": "git fetch origin main:main && git merge main",
"reset-git": "git checkout main && git pull && pnpm run clear-branches",
Expand Down
Loading

0 comments on commit 5e9b574

Please sign in to comment.