René's URL Explorer Experiment


Title: sqlite: add `reader` to `Statement`, aligned with `better-sqlite3` · Issue #67352 · nodejs/node · GitHub

Open Graph Title: sqlite: add `reader` to `Statement`, aligned with `better-sqlite3` · Issue #67352 · nodejs/node

X Title: sqlite: add `reader` to `Statement`, aligned with `better-sqlite3` · Issue #67352 · nodejs/node

Description: What is the problem this feature will solve? Hey 👋 Currently, the only way to tell whether a prepared Statement returns rows is statement.columns().length > 0, which is great when you also need the column metadata, except when all you ne...

Open Graph Description: What is the problem this feature will solve? Hey 👋 Currently, the only way to tell whether a prepared Statement returns rows is statement.columns().length > 0, which is great when you also need the...

X Description: What is the problem this feature will solve? Hey 👋 Currently, the only way to tell whether a prepared Statement returns rows is statement.columns().length > 0, which is great when you also need ...

Opengraph URL: https://github.com/nodejs/node/issues/67352

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlite: add `reader` to `Statement`, aligned with `better-sqlite3`","articleBody":"### What is the problem this feature will solve?\n\nHey 👋\n\nCurrently, the only way to tell whether a prepared `Statement` returns rows is `statement.columns().length > 0`, which is great when you also need the column metadata, except when all you need is a yes/no. `columns()` builds a metadata object per column, so it gets slower the wider the result set is.\n\nQuery builders and ORMs need this answer on every execution, to pick `all()` vs `run()`. Kysely does it for raw SQL, where `insert ... returning` and friends can't be classified from the query alone (https://github.com/kysely-org/kysely/issues/1292). Knex, TypeORM and Prisma 7 do it for every query:\n\nhttps://github.com/knex/knex/blob/e25d54bcb707714a17f5a5744eba5c4246bb4d1d/lib/dialects/better-sqlite3/index.js#L51\nhttps://github.com/typeorm/typeorm/blob/5a572a40bae2f85a1d5f7b87a0aa88bbbaec5ab3/packages/typeorm/src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts#L122\nhttps://github.com/prisma/prisma/blob/0b596ffecfcc55e37d6a7095c03193e2d28b8090/packages/adapter-better-sqlite3/src/better-sqlite3.ts#L110\n\nThese integrations were written against `better-sqlite3`, which exposes it as a `reader` boolean, computed once at prepare time from `sqlite3_column_count`:\n\nhttps://github.com/WiseLibs/better-sqlite3/blob/dbc2ea1165fef1f599b9be12faea33fa5e9d7ffb/src/objects/statement.cpp#L142-L155\n\nOn `node:sqlite`, they're left with paying for `columns()` or guessing. Prisma 8 calls `columns()` on every write, and MikroORM 7 fakes `reader` with regexes over the SQL text:\n\nhttps://github.com/prisma/prisma/blob/557c0d4c1b1061b8fff954dc96598ff4db95d262/packages/3-targets/sqlite/3-driver/src/sqlite-driver.ts#L85\nhttps://github.com/mikro-orm/mikro-orm/blob/14737a2349c834dbb39e1dc82bd5adf32fb2531c/packages/sql/src/dialects/sqlite/NodeSqliteDialect.ts#L31\n\n`node:sqlite` already calls `sqlite3_column_count` internally, but only exposes it through `columns()`:\n\nhttps://github.com/nodejs/node/blob/18b32a3b1552e199a01f1a8d9fd64aa756d3b75b/src/node_sqlite.cc#L4397\n\n`columns().length > 0` on v26.13.0 (darwin-arm64):\n\n```text\ninsert (0 cols)    20 ns/op\nselect 1 col      315 ns/op\nselect 8 cols   2,202 ns/op\nselect 32 cols  8,653 ns/op\n```\n\nFor comparison, `prepare()` of the 8 column select is ~5,200 ns/op, and `better-sqlite3`'s `stmt.reader` is ~8 ns/op.\n\n```js\nimport { Database } from 'node:sqlite'\n\nconst db = new Database(':memory:')\ndb.exec('create table t (id integer primary key, name text, a, b, c, d, e, f)')\n\nconst N = 1_000_000\nconst bench = (label, fn) => {\n  for (let i = 0; i \u003c 1e5; i++) fn()\n  const start = process.hrtime.bigint()\n  for (let i = 0; i \u003c N; i++) fn()\n  console.log(label, (Number(process.hrtime.bigint() - start) / N).toFixed(1), 'ns/op')\n}\n\nfor (const [label, sql] of [\n  ['insert (0 cols)', 'insert into t (name) values (?)'],\n  ['select 1 col', 'select id from t'],\n  ['select 8 cols', 'select * from t'],\n  ['select 32 cols', 'select *, *, *, * from t'],\n]) {\n  const stmt = db.prepare(sql)\n  bench(label, () => stmt.columns().length > 0)\n}\n```\n\n### What is the feature you are proposing to solve the problem?\n\nA side-effect-free `reader` getter on `Statement`, next to `sourceSQL` and `expandedSQL`, with the same semantics as `better-sqlite3` (`true` when the statement returns data):\n\nhttps://github.com/nodejs/node/blob/18b32a3b1552e199a01f1a8d9fd64aa756d3b75b/src/node_sqlite.cc#L4945-L4952\n\n`columns()` itself was added to mirror `better-sqlite3` (#57490). This is purely additive, like `stat()` and `resetStats()` (#64541), and removes one of the differences that keep `better-sqlite3`-based integrations from accepting a `node:sqlite` `Database` as is.\n\n### What alternatives have you considered?\n\nA `columnCount` getter that returns `sqlite3_column_count` as is. It's more general, and `reader` would just be `columnCount > 0`, but integrations written against `better-sqlite3` would have to special-case it.\n\n`sqlite3_stmt_readonly` is not a substitute, `insert ... returning` is not read-only but does return rows.\n\nClassifying the SQL text or the query builder's AST in userland works for builder queries, but not for raw SQL, which is why MikroORM's regexes above can misclassify statements.\n","author":{"url":"https://github.com/igalklebanov","@type":"Person","name":"igalklebanov"},"datePublished":"2026-11-08T22:14:25Z","url":"https://github.com/nodejs/node/issues/67352"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:da63584d-2827-3126-eacb-87e52429518e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE23C:311640:2ED97D2:3B9977A:6B01C481
html-safe-noncea634c2e317d484c8166e2ee2be0fad930366273de00198b1bb6fdc4f3b9c0e6e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjNDOjMxMTY0MDoyRUQ5N0QyOjNCOTk3N0E6NkIwMUM0ODEiLCJ2aXNpdG9yX2lkIjoiMzI4NjY5NDQ5MjQ4OTQ5Mzc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac31bc729e7e5117cd581a52ec581af330f883f7db0d1f2cd5592deeac881c90c3
hovercard-subject-tagissue:6276245161
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/67352/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0bb430cce524e21cc65075b9f9aa0fcbb52115d85eca6578b62b7f3943b8c8bc/nodejs/node/issues/67352
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0bb430cce524e21cc65075b9f9aa0fcbb52115d85eca6578b62b7f3943b8c8bc/nodejs/node/issues/67352
og:image:altWhat is the problem this feature will solve? Hey 👋 Currently, the only way to tell whether a prepared Statement returns rows is statement.columns().length > 0, which is great when you also need the...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameigalklebanov
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/67352#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F67352
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F67352
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/67352
Reloadhttps://github.com/nodejs/node/issues/67352
Reloadhttps://github.com/nodejs/node/issues/67352
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues637 (637)https://github.com/nodejs/node/issues
Pull requests665 (665)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/insights
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67352
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67352
#67658https://github.com/nodejs/node/pull/67658
sqlite: add reader to Statement, aligned with better-sqlite3https://github.com/nodejs/node/issues/67352#top
#67658https://github.com/nodejs/node/pull/67658
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
sqliteIssues and PRs related to the SQLite subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22sqlite%22
https://github.com/igalklebanov
igalklebanovhttps://github.com/igalklebanov
on Nov 8, 2026https://github.com/nodejs/node/issues/67352#issue-6276245161
kysely-org/kysely#1292https://github.com/kysely-org/kysely/issues/1292
https://github.com/knex/knex/blob/e25d54bcb707714a17f5a5744eba5c4246bb4d1d/lib/dialects/better-sqlite3/index.js#L51https://github.com/knex/knex/blob/e25d54bcb707714a17f5a5744eba5c4246bb4d1d/lib/dialects/better-sqlite3/index.js#L51
https://github.com/typeorm/typeorm/blob/5a572a40bae2f85a1d5f7b87a0aa88bbbaec5ab3/packages/typeorm/src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts#L122https://github.com/typeorm/typeorm/blob/5a572a40bae2f85a1d5f7b87a0aa88bbbaec5ab3/packages/typeorm/src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts#L122
https://github.com/prisma/prisma/blob/0b596ffecfcc55e37d6a7095c03193e2d28b8090/packages/adapter-better-sqlite3/src/better-sqlite3.ts#L110https://github.com/prisma/prisma/blob/0b596ffecfcc55e37d6a7095c03193e2d28b8090/packages/adapter-better-sqlite3/src/better-sqlite3.ts#L110
https://github.com/WiseLibs/better-sqlite3/blob/dbc2ea1165fef1f599b9be12faea33fa5e9d7ffb/src/objects/statement.cpp#L142-L155https://github.com/WiseLibs/better-sqlite3/blob/dbc2ea1165fef1f599b9be12faea33fa5e9d7ffb/src/objects/statement.cpp#L142-L155
https://github.com/prisma/prisma/blob/557c0d4c1b1061b8fff954dc96598ff4db95d262/packages/3-targets/sqlite/3-driver/src/sqlite-driver.ts#L85https://github.com/prisma/prisma/blob/557c0d4c1b1061b8fff954dc96598ff4db95d262/packages/3-targets/sqlite/3-driver/src/sqlite-driver.ts#L85
https://github.com/mikro-orm/mikro-orm/blob/14737a2349c834dbb39e1dc82bd5adf32fb2531c/packages/sql/src/dialects/sqlite/NodeSqliteDialect.ts#L31https://github.com/mikro-orm/mikro-orm/blob/14737a2349c834dbb39e1dc82bd5adf32fb2531c/packages/sql/src/dialects/sqlite/NodeSqliteDialect.ts#L31
node/src/node_sqlite.cchttps://github.com/nodejs/node/blob/18b32a3b1552e199a01f1a8d9fd64aa756d3b75b/src/node_sqlite.cc#L4397
18b32a3https://github.com/nodejs/node/commit/18b32a3b1552e199a01f1a8d9fd64aa756d3b75b
node/src/node_sqlite.cchttps://github.com/nodejs/node/blob/18b32a3b1552e199a01f1a8d9fd64aa756d3b75b/src/node_sqlite.cc#L4945-L4952
18b32a3https://github.com/nodejs/node/commit/18b32a3b1552e199a01f1a8d9fd64aa756d3b75b
#57490https://github.com/nodejs/node/pull/57490
#64541https://github.com/nodejs/node/pull/64541
https://github.com/semimikoh
semimikohhttps://github.com/semimikoh
on Nov 9, 2026https://github.com/nodejs/node/issues/67352#issuecomment-6732851886
MikeMcC399https://github.com/MikeMcC399
on Nov 9, 2026https://github.com/nodejs/node/issues/67352#event-35547333438
MikeMcC399https://github.com/MikeMcC399
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
sqliteIssues and PRs related to the SQLite subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22sqlite%22
on Nov 9, 2026https://github.com/nodejs/node/issues/67352#event-35547351260
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Nov 9, 2026https://github.com/nodejs/node/issues/67352#event-35547353663
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Nov 9, 2026https://github.com/nodejs/node/issues/67352
https://github.com/Renegade334
Renegade334https://github.com/Renegade334
on Nov 9, 2026https://github.com/nodejs/node/issues/67352#issuecomment-6750224681
https://github.com/igalklebanov
igalklebanovhttps://github.com/igalklebanov
on Nov 10, 2026https://github.com/nodejs/node/issues/67352#issuecomment-6761953560
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/67352
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67352
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
sqliteIssues and PRs related to the SQLite subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22sqlite%22
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.