Skip to content

fix: accept tabs after the GO batch terminator - #810

Closed
Raymondriter wants to merge 1 commit into
microsoft:mainfrom
Raymondriter:fix/go-tab-batch-terminator
Closed

Raymondriter wants to merge 1 commit into
microsoft:mainfrom
Raymondriter:fix/go-tab-batch-terminator

Conversation

@Raymondriter

Copy link
Copy Markdown

Fixes #792

Problem

batchTerminatorRegex only allowed spaces between GO and its count or the end of the line ((?:[ ]+(.*$)|$)). A line like GO<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 with Incorrect 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 in commands.go already use. readCommand already passes tabs through, so the regex was the only thing rejecting them. Custom terminators set with -c get the same behaviour.

Tests

  • TestCommandParsing: GO, GO\t\t, go\t5, \tGO \t 5
  • TestCustomBatchSeparator: a custom terminator followed by a tab
  • TestBatchNext: select 1\nGO\t\t yields one statement and a GO command

These fail on main and pass with the change. I also ran the full suite against a local SQL Server 2022 container. main and this branch have the same results; the only failures are the environment-dependent install/ADS/editor tests. End to end, a script with GO<tab><tab> between two batches now runs both batches instead of failing with a syntax error.

🤖 Generated with Claude Code

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>
Copilot AI lite review requested due to automatic review settings September 14, 2026 16:55

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.

🟢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go + tab is not understood.

2 participants