8000 fix(typegen): allow composite type attributes to be null · nikolubbe/postgres-meta@aa71282 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa71282

Browse files
committed
fix(typegen): allow composite type attributes to be null
1 parent a11bae5 commit aa71282

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/server/templates/typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export interface Database {
387387
type.name,
388388
types,
389389
schemas
390-
)}`
390+
)} | null`
391391
}
392392
return `${JSON.stringify(name)}: unknown`
393393
})}

test/db/01-memes.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

2+
CREATE TYPE public.composite_t AS (attr int);
23

34
CREATE TABLE public.category (
45
id serial NOT NULL PRIMARY KEY,
5-
name text NOT NULL
6+
name text NOT NULL,
7+
composite composite_t
68
);
79

810
-- Fake policies

test/server/typegen.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ test('typegen', async () => {
1919
Tables: {
2020
category: {
2121
Row: {
22+
composite: Database["public"]["CompositeTypes"]["composite_t"] | null
2223
id: number
2 B3CF 324
name: string
2425
}
2526
Insert: {
27+
composite?: Database["public"]["CompositeTypes"]["composite_t"] | null
2628
id?: number
2729
name: string
2830
}
2931
Update: {
32+
composite?: Database["public"]["CompositeTypes"]["composite_t"] | null
3033
id?: number
3134
name?: string
3235
}
@@ -264,7 +267,9 @@ test('typegen', async () => {
264267
user_status: "ACTIVE" | "INACTIVE"
265268
}
266269
CompositeTypes: {
267-
[_ in never]: never
270+
composite_t: {
271+
attr: number | null
272+
}
268273
}
269274
}
270275
}

0 commit comments

Comments
 (0)
0