From 5d16ad01e8d1b4c9e38b6f4ba4544d563813d887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Fri, 20 Nov 2026 11:03:49 -0300 Subject: [PATCH] sqlite: add statement.columnCount getter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a getter to `Statement` that returns the number of columns in the prepared statement's result set, wrapping `sqlite3_column_count()`. Fixes: https://github.com/nodejs/node/issues/67352 Assisted-by: Claude Code Signed-off-by: Guilherme Araújo --- doc/api/sqlite.md | 14 +++++++ src/node_sqlite.cc | 13 +++++++ src/node_sqlite.h | 2 + test/parallel/test-sqlite-statement.js | 54 ++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) diff --git a/doc/api/sqlite.md b/doc/api/sqlite.md index 708763a2c3c1..422df94ea540 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -1324,6 +1324,19 @@ aggregate function, or a [`'sqlite.db.query'`][] subscriber. Idle statements on the same connection can be finalized from such a callback. This method is a wrapper around [`sqlite3_finalize()`][]. +### `statement.columnCount` + + + +* Type: {number} The number of columns in the result set returned by the + prepared statement. + +This property is `0` for statements that do not return data, such as `INSERT`, +`UPDATE`, and `DELETE` statements without a `RETURNING` clause. This property +is a wrapper around [`sqlite3_column_count()`][]. + ### `statement.columns()`