Skip to content

Commit ab1dc67

Browse files
authored
Merge pull request #614 from arin-c/fix/typegen-composite-types-not-nullable
fix(typegen): allow composite type attributes to be null
2 parents 0dbbdb6 + 46c1c60 commit ab1dc67

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/server/templates/typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export type Database = {
367367
const type = types.find(({ id }) => id === type_id)
368368
let tsType = 'unknown'
369369
if (type) {
370-
tsType = pgTypeToTsType(type.name, types, schemas)
370+
tsType = `${pgTypeToTsType(type.name, types, schemas)} | null`
371371
}
372372
return `${JSON.stringify(name)}: ${tsType}`
373373
})}

test/server/typegen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ test('typegen', async () => {
374374
}
375375
CompositeTypes: {
376376
composite_type_with_array_attribute: {
377-
my_text_array: string[]
377+
my_text_array: string[] | null
378378
}
379379
}
380380
}
@@ -855,7 +855,7 @@ test('typegen w/ one-to-one relationships', async () => {
855855
}
856856
CompositeTypes: {
857857
composite_type_with_array_attribute: {
858-
my_text_array: string[]
858+
my_text_array: string[] | null
859859
}
860860
}
861861
}

0 commit comments

Comments
 (0)