Skip to content

Commit

Permalink
Merge pull request #614 from arin-c/fix/typegen-composite-types-not-n…
Browse files Browse the repository at this point in the history
…ullable

fix(typegen): allow composite type attributes to be null
  • Loading branch information
soedirgo authored Mar 12, 2024
2 parents 0dbbdb6 + 46c1c60 commit ab1dc67
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/templates/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export type Database = {
const type = types.find(({ id }) => id === type_id)
let tsType = 'unknown'
if (type) {
tsType = pgTypeToTsType(type.name, types, schemas)
tsType = `${pgTypeToTsType(type.name, types, schemas)} | null`
}
return `${JSON.stringify(name)}: ${tsType}`
})}
Expand Down
4 changes: 2 additions & 2 deletions test/server/typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ test('typegen', async () => {
}
CompositeTypes: {
composite_type_with_array_attribute: {
my_text_array: string[]
my_text_array: string[] | null
}
}
}
Expand Down Expand Up @@ -855,7 +855,7 @@ test('typegen w/ one-to-one relationships', async () => {
}
CompositeTypes: {
composite_type_with_array_attribute: {
my_text_array: string[]
my_text_array: string[] | null
}
}
}
Expand Down

0 comments on commit ab1dc67

Please sign in to comment.