Skip to content

feat: add -j flag for raw error messages#624

Open
dlevy-msft-sql wants to merge 5 commits intomicrosoft:mainfrom
dlevy-msft-sql:feature/raw-error-messages
Open

feat: add -j flag for raw error messages#624
dlevy-msft-sql wants to merge 5 commits intomicrosoft:mainfrom
dlevy-msft-sql:feature/raw-error-messages

Conversation

@dlevy-msft-sql
Copy link
Contributor

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

Testing

  • All existing tests pass
  • Added 3 command line argument tests in cmd/sqlcmd/sqlcmd_test.go
  • Added TestFormatterRawErrors unit test in pkg/sqlcmd/format_test.go

Fixes part of #292

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
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 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 RawErrors boolean field to SQLCmdArguments struct and registered the -j/--raw-errors flag
  • Modified NewSQLCmdDefaultFormatter to accept a rawErrors parameter 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
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 8 out of 8 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 8 out of 8 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 8 out of 8 changed files in this pull request and generated no new 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
@dlevy-msft-sql dlevy-msft-sql changed the title Add -j (--raw-errors) flag for printing raw error messages feat: add -j flag for raw error messages Feb 5, 2026
@dlevy-msft-sql dlevy-msft-sql force-pushed the feature/raw-error-messages branch from 811bf9b to 2728e07 Compare February 6, 2026 00:40
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