Skip to content

feat: implement multi-line EXIT(query) support#636

Open
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql:exit-multiline
Open

feat: implement multi-line EXIT(query) support#636
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql:exit-multiline

Conversation

@dlevy-msft-sql
Copy link
Contributor

In interactive mode, EXIT(query) can now span multiple lines when parentheses are unbalanced. The shell prompts for continuation lines until parentheses balance, matching ODBC sqlcmd behavior. Adds isExitParenBalanced() function, readExitContinuation() for prompting, updates exitCommand(), adds tests, and removes README limitation note.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements multi-line EXIT(query) support in interactive mode for go-sqlcmd. When an EXIT command with parentheses is entered and the parentheses are unbalanced, the shell now prompts for continuation lines until the parentheses balance, matching the behavior of ODBC sqlcmd.

Changes:

  • Added isExitParenBalanced() function to check if parentheses in EXIT command arguments are balanced
  • Added readExitContinuation() function to prompt for and read continuation lines in interactive mode
  • Updated exitCommand() to call continuation logic when parentheses are unbalanced
  • Added comprehensive test suite for isExitParenBalanced()
  • Removed the README limitation note about EXIT(query) not supporting multi-line

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/sqlcmd/commands.go Implements core multi-line EXIT(query) functionality with parentheses balancing check and continuation prompt logic
pkg/sqlcmd/commands_test.go Adds test cases for the new isExitParenBalanced() function covering various edge cases
README.md Removes the documented limitation about EXIT(query) not supporting multi-line queries

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@dlevy-msft-sql dlevy-msft-sql self-assigned this Jan 25, 2026
@dlevy-msft-sql dlevy-msft-sql added sqlcmd switch switch in existing sqlcmd Size: S Small issue (less than one week effort) labels Jan 25, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@dlevy-msft-sql dlevy-msft-sql changed the title Implement multi-line EXIT(query) support feat: implement multi-line EXIT(query) support Feb 5, 2026
In interactive mode, EXIT(query) can now span multiple lines when parentheses
are unbalanced. Handles SQL strings, comments, and bracket identifiers correctly.

Includes protection against infinite loops (max 1000 continuation lines) and
user-friendly error messages for EOF/incomplete commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: S Small issue (less than one week effort) sqlcmd switch switch in existing sqlcmd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant