Skip to content

fix: preserve loadFile transaction errors - #315

Merged
chrispader merged 3 commits into
margelo:mainfrom
huytdps13400:fix/308-preserve-load-file-errors
Oct 1, 2026
Merged

chrispader merged 3 commits into
margelo:mainfrom
huytdps13400:fix/308-preserve-load-file-errors

Conversation

@huytdps13400

@huytdps13400 huytdps13400 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

A failed statement during a SQL-file import currently rolls back twice, and the second rollback masks the original SQL error. This PR gives the importer one transaction-finalization path and preserves the file path, failing line and command, and primary error. Rollback failures are appended without replacing the import failure.

The fix uses the current retained connection and keeps its lock for the entire import. It attempts rollback only after BEGIN succeeds, uses RAII for the input file, and registers an iOS example regression. Local host regressions against the bundled SQLite cover statement, BEGIN, COMMIT, and rollback failures, including connection reuse.

Reproduction

Import a file with a valid INSERT on line 1 and invalid SQL on line 2. The managed method must throw or reject with CouldNotLoadFile, the path, line 2, the failing command, and the original syntax error. The inserted row must be absent, and a subsequent write on the same connection must succeed.

Fixes #308.

Give importSqlFile one transaction-finalization path, retain failing command context, and append rollback failures without masking the primary cause. Closes margelo#308.
@chrispader chrispader added bug Incorrect behavior or a change that fixes it. area:runtime Database lifecycle, SQL execution, transactions, or native runtime. labels Sep 29, 2026
@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown

@chrispader is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

@chrispader

Copy link
Copy Markdown
Member

Thanks for the PR @huytdps13400 ! 🙌🏼

@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-nitro-sqlite Ready Ready Preview Oct 1, 2026 10:13am UTC

Request Review

@chrispader
chrispader merged commit b393c5f into margelo:main Oct 1, 2026
1 of 2 checks passed

This branch was successfully deployed

1 active deployment
Preview — 87efa6db Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Database lifecycle, SQL execution, transactions, or native runtime. bug Incorrect behavior or a change that fixes it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loadFile masks statement errors by rolling back twice

2 participants