Repository navigation
fix: make :on error exit override an earlier :on error ignore - #846
Hitarth Jain (Yeagerist0) wants to merge 1 commit into
Conversation
:on error ignore sets IgnoreError, but :on error exit only set ExitOnError. Run stops on errors only when ExitOnError && !IgnoreError, so the script kept running.
|
Hitarth Jain (@Yeagerist0) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change making :on error exit override an earlier :on error ignore.
No open issues 🎉
What changed in this PR
Fixes sqlcmd script error handling so :on error exit overrides an earlier :on error ignore.
Changes:
- Clears
IgnoreErrorwhen selecting exit-on-error behavior. - Adds regression tests for the state change and script termination, without requiring SQL Server.
| File | Description |
|---|---|
pkg/sqlcmd/onerror_command_test.go |
Tests that exit overrides ignore and stops execution after an error. |
pkg/sqlcmd/commands.go |
Resets IgnoreError in the exit branch. |
Review effort: Balanced
In a script,
:on error exithas no effect after an earlier:on error ignore:ignoresetsIgnoreError = true,exitonly setsExitOnError = true, andRunstops only whenExitOnError && !IgnoreError. The fix clearsIgnoreErrorin theexitbranch.Testing: both new tests fail on
mainand pass with the change; they need no SQL Server.go build ./...passes. I did not run the tests that need a SQL Server instance, includingTestOnErrorCommand.commands.gokeeps its CRLF line endings.AI disclosure: Claude Code found the bug and wrote the fix, tests and this description; the results above are from local runs.