Skip to content

sqlite: propagate option getter errors and dedupe boolean options - #66748

Open
araujogui wants to merge 2 commits into
nodejs:mainfrom
araujogui:sqlite-option-parsing
Open

araujogui wants to merge 2 commits into
nodejs:mainfrom
araujogui:sqlite-option-parsing

Conversation

@araujogui

Copy link
Copy Markdown
Member

new Database(path, options) read readBigInts, returnArrays, allowBareNamedParameters and allowUnknownNamedParameters without returning when the getter threw. The exception was lost, the constructor succeeded, and the database file was created anyway. Those options now propagate the error, and a regression test covers them.

Every boolean option in the binding now goes through a single ReadOptionalBool() helper instead of repeating the read/validate/throw logic for each one. Options are read in the same order and error messages are unchanged.

The readBigInts, returnArrays, allowBareNamedParameters and
allowUnknownNamedParameters options were read with
`if (Get().ToLocal())`, so a throwing getter left an exception pending
while the constructor carried on. Option parsing continued, the
database was opened, and the exception was lost, leaving a database
file on disk for a constructor call that should have failed.

Return as soon as reading any of these options fails, matching how
every other option is handled.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Assisted-by: Claude
Reading an optional boolean option took about 15 lines of
Get/IsUndefined/IsBoolean/throw, repeated for every option across
Database's constructor, prepare(), function(), aggregate() and
createModule(). That repetition is also what let a missing early
return slip into four of the constructor's options.

Add ReadOptionalBool(), which reads one property, validates it and
reports whether an exception is pending, and use it for every boolean
option. Options are still read in the same order, and the error
messages are unchanged.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Assisted-by: Claude
Copilot AI balanced review requested due to automatic review settings October 15, 2026 02:14
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.82540% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.49%. Comparing base (782a3ac) to head (5f02b11).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 96.82% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66748      +/-   ##
==========================================
+ Coverage   90.47%   90.49%   +0.02%     
==========================================
  Files         791      797       +6     
  Lines      277225   277250      +25     
  Branches    53313    53273      -40     
==========================================
+ Hits       250829   250908      +79     
+ Misses      16801    16780      -21     
+ Partials     9595     9562      -33     
Files with missing lines Coverage Δ
src/node_sqlite.cc 82.48% <96.82%> (+0.16%) ⬆️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants