From 7ec187ddc16d5e90605ab935ade6296daceebfc7 Mon Sep 17 00:00:00 2001 From: Chiri Vulpes Date: Tue, 3 Dec 2024 22:44:05 +1300 Subject: [PATCH] Return row count for update when not returning any columns --- src/statements/Update.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/statements/Update.ts b/src/statements/Update.ts index 4427daf..00cbd0e 100644 --- a/src/statements/Update.ts +++ b/src/statements/Update.ts @@ -4,7 +4,7 @@ import Schema, { TableSchema } from "../Schema"; import Expression, { ExpressionInitialiser } from "../expressions/Expression"; import Statement from "./Statement"; -export default class UpdateTable[], VARS = {}> extends Statement { +export default class UpdateTable extends Statement { private vars: any[]; public constructor (public readonly tableName: string | undefined, public readonly schema: SCHEMA, vars?: any[]) { @@ -43,6 +43,7 @@ export default class UpdateTable | "*")[]; + public returning (): UpdateTable; public returning[]> (...columns: RETURNING_COLUMNS): UpdateTable }[], VARS>; public returning | "*"> (columns: RETURNING_COLUMN): UpdateTable : RETURNING_COLUMN]: OutputTypeFromString }[], VARS>; public returning (...columns: (Schema.Column | "*")[]) { @@ -58,6 +59,6 @@ export default class UpdateTable) { - return output.rows as RESULT; + return (!this.returningColumns?.length ? output.rowCount : output.rows) as RESULT; } } \ No newline at end of file