-
Notifications
You must be signed in to change notification settings - Fork 80
Add -j (--raw-errors) flag for printing raw error messages #624
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?
Add -j (--raw-errors) flag for printing raw error messages #624
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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 8 out of 8 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 8 out of 8 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 8 out of 8 changed files in this pull request and generated no new comments.
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