-
Notifications
You must be signed in to change notification settings - Fork 79
Implement multi-line EXIT(query) support #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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. Changes: - Add isExitParenBalanced() to check paren balance respecting quotes - Add readExitContinuation() to prompt for additional lines - Update exitCommand() to call continuation when needed - Add TestIsExitParenBalanced tests - Remove limitation note from README
There was a problem hiding this 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 |
There was a problem hiding this 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.
- Fix isExitParenBalanced to handle SQL Server quote escaping rules:
- Escaped single quotes ('') inside string literals
- Escaped bracket identifiers (]])
- Add test cases for escaped quotes in TestIsExitParenBalanced
- Add comprehensive TestReadExitContinuation tests:
- Continuation lines until balanced
- Error handling on readline failure
- Multiple continuation lines
- Early return for already balanced input
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
- Add TestExitCommandMultiLineInteractive: exercises the full multi-line EXIT flow with real database connection (unbalanced parens -> read continuation -> execute query -> verify exit code) - Add 'Interactive Mode Commands' section to README with EXIT examples showing both single-line and multi-line usage with continuation prompt
There was a problem hiding this 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.
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.