Repository navigation
fix: accept tabs after the GO batch terminator - #810
Closed
Raymondriter wants to merge 1 commit into
Closed
Raymondriter wants to merge 1 commit into
Raymondriter wants to merge 1 commit into
Conversation
The batch terminator regex only allowed spaces between GO and its count or the end of the line, so a line such as "GO<tab><tab>" was passed to the server as SQL instead of ending the batch. ODBC sqlcmd and SSMS accept tabs there (the Northwind creation script relies on it). Allow tabs as well as spaces, matching the other commands. Fixes microsoft#792 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues were identified, and the changes include focused test coverage.
Pull request overview
Updates batch terminator parsing to accept tabs after GO and custom terminators.
Changes:
- Allows tabs alongside spaces in terminator parsing.
- Adds command, custom separator, and batch splitting tests.
File summaries
| File | Summary |
|---|---|
pkg/sqlcmd/commands.go |
Accepts tabs after batch terminators. |
pkg/sqlcmd/commands_test.go |
Tests tab-separated terminators and arguments. |
pkg/sqlcmd/batch_test.go |
Tests batch splitting with tabs. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Fixes #792
Problem
batchTerminatorRegexonly allowed spaces betweenGOand its count or the end of the line ((?:[ ]+(.*$)|$)). A line likeGO<tab><tab>, as used in the Northwind creation script, wasn't treated as a batch terminator. It was sent to the server as SQL and failed withIncorrect syntax near 'GO'. ODBC sqlcmd and SSMS accept it.Fix
Allow tabs as well as spaces after the terminator (
[\t ]+), the same character class the other commands incommands.goalready use.readCommandalready passes tabs through, so the regex was the only thing rejecting them. Custom terminators set with-cget the same behaviour.Tests
TestCommandParsing:GO,GO\t\t,go\t5,\tGO \t 5TestCustomBatchSeparator: a custom terminator followed by a tabTestBatchNext:select 1\nGO\t\tyields one statement and aGOcommandThese fail on
mainand pass with the change. I also ran the full suite against a local SQL Server 2022 container.mainand this branch have the same results; the only failures are the environment-dependent install/ADS/editor tests. End to end, a script withGO<tab><tab>between two batches now runs both batches instead of failing with a syntax error.🤖 Generated with Claude Code