feat: implement multi-line EXIT(query) support#636
Open
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: implement multi-line EXIT(query) support#636dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
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 |
a4dd987 to
b38d203
Compare
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.
d3961ef to
bc4b6b6
Compare
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.
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.