Skip to content

sqlite: add database.transaction() - #67854

Open
araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:sqlite-transaction
Open

araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:sqlite-transaction

Conversation

@araujogui

Copy link
Copy Markdown
Member

Adds database.transaction(fn[, options]), which runs fn inside a transaction. It commits when fn returns and rolls back if fn throws.

Calls made while a transaction is already active use a savepoint, so they can be nested. options.mode selects deferred (default), immediate or exclusive. If fn returns a Promise, the transaction is rolled back and an error is thrown.

Unlike better-sqlite3, fn runs immediately instead of being wrapped in a returned function.

Fixes: #57431

Add a helper that runs a function inside a transaction. The
transaction is committed when the function returns and rolled back
if it throws. Calls made while a transaction is already active use
a savepoint, so they can be nested.

Fixes: nodejs#57431
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 19:59
@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 insufficient remaining quota. Try requesting a review at a lower effort level.

@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 Nov 28, 2026
@codecov

codecov Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.89041% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.53%. Comparing base (d3f8545) to head (aa96ab3).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 95.89% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67854      +/-   ##
==========================================
- Coverage   90.53%   90.53%   -0.01%     
==========================================
  Files         805      805              
  Lines      285842   285987     +145     
  Branches    55187    55240      +53     
==========================================
+ Hits       258793   258916     +123     
- Misses      17167    17183      +16     
- Partials     9882     9888       +6     
Files with missing lines Coverage Δ
src/node_errors.h 86.95% <ø> (ø)
src/node_sqlite.h 88.13% <ø> (ø)
src/node_sqlite.cc 83.19% <95.89%> (+0.27%) ⬆️

... and 29 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.

Transactions for SQLite

3 participants