Skip to content

Commit

Permalink
fix code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 committed Jan 1, 2024
1 parent c5582b7 commit cf55cb8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/schema/src/plugins/zod/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,13 @@ async function generateModelSchema(model: DataModel, project: Project, output: s

function makePartial(schema: string, fields?: string[]) {
if (fields) {
return `${schema}.partial({
${fields.map((f) => `${f}: true`).join(', ')},
if (fields.length === 0) {
return schema;
} else {
return `${schema}.partial({
${fields.map((f) => `${f}: true`).join(', ')}
})`;
}
} else {
return `${schema}.partial()`;
}
Expand Down

0 comments on commit cf55cb8

Please sign in to comment.