From 319564699638c080b73d506bcaad186ecc4a8236 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Mon, 2 Dec 2024 14:49:06 +0100 Subject: [PATCH] fix(sql): Fix QueryResult typings (#1928) * fix(sql): Fix QueryResult typings closes #1893 * Create fix-sql-queryresult-type.md --------- Co-authored-by: Tillmann <28728469+tweidinger@users.noreply.github.com> --- .changes/fix-sql-queryresult-type.md | 5 +++++ plugins/sql/guest-js/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changes/fix-sql-queryresult-type.md diff --git a/.changes/fix-sql-queryresult-type.md b/.changes/fix-sql-queryresult-type.md new file mode 100644 index 00000000..f93f741c --- /dev/null +++ b/.changes/fix-sql-queryresult-type.md @@ -0,0 +1,5 @@ +--- +sql-js: patch +--- + +Fixed the QueryResult typing by marking `lastInsertId` as optional to reflect postgres-only changes made in the 2.0.0 release. diff --git a/plugins/sql/guest-js/index.ts b/plugins/sql/guest-js/index.ts index e200936e..11d39e70 100644 --- a/plugins/sql/guest-js/index.ts +++ b/plugins/sql/guest-js/index.ts @@ -10,12 +10,12 @@ export interface QueryResult { /** * The last inserted `id`. * - * This value is always `0` when using the Postgres driver. If the + * This value is not set for Postgres databases. If the * last inserted id is required on Postgres, the `select` function * must be used, with a `RETURNING` clause * (`INSERT INTO todos (title) VALUES ($1) RETURNING id`). */ - lastInsertId: number + lastInsertId?: number } /**