Repository navigation
fix(import): stop at the first failed statement, and say what already ran - #580
Merged
Merged
Conversation
… ran Closes #365. The loop caught every error, counted it, and carried on to the end of the file. A dump whose CREATE TABLE failed still executed all of its INSERTs against whatever was already there — so the import did not abort partway, it applied the whole file to a database in a state the file did not expect. Stopping is now the default, and the summary says where it stopped and how many statements had already applied. Continuing is a checkbox for the cases where it is wanted — a file of independent INSERTs, say — and the existing test for the error list opts into it, since a list needs more than one error. The issue's repro describes "stopOnError=true (default)". There was no such option; the behaviour it assumed already existed is what this adds. ## The proposed fix could not work It asks for the run to be wrapped in a transaction with a full rollback on error. Two independent reasons that does nothing: DDL commits implicitly, and a dump is full of CREATE, DROP and ALTER. Verified earlier in this campaign: START TRANSACTION, ALTER TABLE, ROLLBACK leaves the change in place. And each statement goes through its own executeQuery call, so each takes its own pooled connection. A START TRANSACTION sent in one call would not cover the next — the transaction would silently apply to nothing. So the UI says so instead of implying otherwise: statements that already ran stay applied either way, and files containing CREATE, DROP or ALTER cannot be rolled back. A test asserts that sentence is present, because the temptation to promise atomicity here is exactly what the issue did. ## Also The checkbox has an aria-label. Its visible label wraps a second line of explanation, so the accessible name was the whole paragraph. Four tests. Three fail against the previous version; the fourth asserts the rollback wording, which had nothing to fail against. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #365.
The bug is the opposite of what the issue describes
The loop caught every error, counted it, and carried on to the end of the file:
So a dump whose
CREATE TABLEfailed still executed all of itsINSERTs against whatever was already there. It didn't abort partway — it applied the whole file to a database in a state the file didn't expect.The issue's repro says "with stopOnError=true (default)". There was no such option. The behaviour it assumed already existed is what this adds.
Stopping is now the default; the summary says where it stopped and how many statements had already applied. Continuing is a checkbox for when it's wanted — a file of independent INSERTs, say.
The proposed fix couldn't work
It asks for the run to be wrapped in a transaction with a full rollback. Two independent reasons that does nothing:
CREATE/DROP/ALTER. Verified earlier in this campaign:START TRANSACTION; ALTER TABLE …; ROLLBACK;leaves the change in place.executeQuery, so each takes its own pooled connection. ASTART TRANSACTIONsent in one call wouldn't cover the next — the transaction would silently apply to nothing.So the UI says so rather than implying otherwise: statements that already ran stay applied either way, and files containing CREATE, DROP or ALTER cannot be rolled back. There's a test asserting that sentence is present — the temptation to promise atomicity here is exactly what the issue did.
Also
The checkbox has an
aria-label. Its visible label wraps a second line of explanation, so the accessible name was the entire paragraph.Tests
Four. Three fail against the previous version; the fourth asserts the rollback wording, which had nothing to fail against.
One existing browser test — "shows error count and error list" — now turns stopping off, because a list needs more than one error. Its intent is preserved rather than its assertion weakened.
1789 unit + 299 browser green; tsc/dprint/eslint clean.
Left in import
#366 (no row-size or file-size cap) and #578 (empty cell → NULL). Both need changes in
csv-parser, so they pair naturally.🤖 Generated with Claude Code