feat: add -j flag for raw error messages#624
Open
dlevy-msft-sql wants to merge 5 commits intomicrosoft:mainfrom
Open
feat: add -j flag for raw error messages#624dlevy-msft-sql wants to merge 5 commits intomicrosoft:mainfrom
dlevy-msft-sql wants to merge 5 commits intomicrosoft:mainfrom
Conversation
Implements the -j flag from ODBC sqlcmd that prints only the error message without the Msg/Level/State/Server/Line header prefix. Changes: - Add RawErrors field to SQLCmdArguments struct - Add -j/--raw-errors flag in cmd/sqlcmd/sqlcmd.go - Add rawErrors parameter to NewSQLCmdDefaultFormatter - Modify AddError in format.go to skip header when rawErrors is true - Add command line tests for -j flag - Add unit test TestFormatterRawErrors - Update README.md with documentation
There was a problem hiding this comment.
Pull request overview
This PR implements the -j (or --raw-errors) command-line flag from ODBC sqlcmd that prints only error messages without the structured header prefix (Msg/Level/State/Server/Procedure/Line).
Changes:
- Added
RawErrorsboolean field toSQLCmdArgumentsstruct and registered the-j/--raw-errorsflag - Modified
NewSQLCmdDefaultFormatterto accept arawErrorsparameter and conditionally skip error header formatting - Added comprehensive test coverage including command-line flag tests and unit tests for the formatter behavior
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/sqlcmd/sqlcmd.go | Added RawErrors field to SQLCmdArguments struct and registered the -j/--raw-errors flag |
| cmd/sqlcmd/sqlcmd_test.go | Added three test cases to verify command-line flag parsing for -j and --raw-errors |
| pkg/sqlcmd/format.go | Added rawErrors field to sqlCmdFormatterType and modified AddError to conditionally skip header based on rawErrors flag |
| pkg/sqlcmd/format_test.go | Added TestFormatterRawErrors unit test to verify both normal and raw error output modes |
| pkg/sqlcmd/sqlcmd_test.go | Updated all NewSQLCmdDefaultFormatter calls to include the new rawErrors parameter (false for test fixtures) |
| pkg/sqlcmd/commands_test.go | Updated NewSQLCmdDefaultFormatter call to include the new rawErrors parameter |
| internal/sql/mssql.go | Updated NewSQLCmdDefaultFormatter call to include the new rawErrors parameter |
| README.md | Added documentation for the new -j/--raw-errors flag in the Miscellaneous enhancements section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add TestFormatterErrorWithProcName test - Verifies that errors with ProcName include Procedure in the header
811bf9b to
2728e07
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.
Implements the -j flag from ODBC sqlcmd that prints only the error message without the Msg/Level/State/Server/Line header prefix.
Changes
Testing
Fixes part of #292