From d87f3859940bed70f43081a9b25211526a439c0f Mon Sep 17 00:00:00 2001 From: Igal Klebanov Date: Sat, 10 Dec 2022 18:09:29 +0200 Subject: [PATCH] add `numAffectedRows` @ `PlanetScaleConnection.executeQuery`. --- src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 56f6936..4207978 100644 --- a/src/index.ts +++ b/src/index.ts @@ -124,10 +124,16 @@ class PlanetScaleConnection implements DatabaseConnection { throw (results as any).error } + const numAffectedRows = results.rowsAffected == null ? undefined : BigInt(results.rowsAffected) + return { insertId: results.insertId !== null && results.insertId.toString() !== '0' ? BigInt(results.insertId) : undefined, rows: results.rows as O[], - numUpdatedOrDeletedRows: results.rowsAffected == null ? undefined : BigInt(results.rowsAffected), + // @ts-ignore replaces `QueryResult.numUpdatedOrDeletedRows` in kysely > 0.22 + // following https://github.com/koskimas/kysely/pull/188 + numAffectedRows, + // deprecated in kysely > 0.22, keep for backward compatibility. + numUpdatedOrDeletedRows: numAffectedRows, } }