Skip to content

Commit 970424e

Browse files
committed
fix(code-gen): generate where-parameter as optional in count and delete queries
1 parent f31ef02 commit 970424e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/code-gen/src/database/ts-postgres.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export function tsPostgresGenerateWhere(
357357
// Function
358358
fileBlockStart(
359359
file,
360-
`export function ${model.name}Where(where: ${contextNames.whereType.inputType}, options: { skipValidator?: boolean, shortName?: string } = {}): QueryPart`,
360+
`export function ${model.name}Where(where: ${contextNames.whereType.inputType} = {}, options: { skipValidator?: boolean, shortName?: string } = {}): QueryPart`,
361361
);
362362

363363
fileWrite(file, `options.shortName ??= "${model.shortName}."`);
@@ -370,7 +370,7 @@ export function tsPostgresGenerateWhere(
370370

371371
fileWrite(
372372
file,
373-
`const { error, value } = ${contextNames.whereType.validatorFunction}(where ?? {});`,
373+
`const { error, value } = ${contextNames.whereType.validatorFunction}(where);`,
374374
);
375375

376376
fileBlockStart(file, `if (error)`);
@@ -524,7 +524,7 @@ export function tsPostgresGenerateCount(
524524
// Function
525525
fileBlockStart(
526526
file,
527-
`async function ${model.name}Count(sql: Postgres, where: ${contextNames.whereType.inputType}): Promise<number>`,
527+
`async function ${model.name}Count(sql: Postgres, where?: ${contextNames.whereType.inputType}): Promise<number>`,
528528
);
529529

530530
fileWrite(

0 commit comments

Comments
 (0)