Add ASCII table query output format#609
Add ASCII table query output format#6090x7FFFFFFFFFFFFFFF wants to merge 12 commits intomicrosoft:mainfrom
Conversation
|
thx for opening a PR! |
There was a problem hiding this comment.
Pull request overview
This pull request adds a new ASCII table output format to sqlcmd, providing a more visually structured alternative to the default horizontal format. The feature is activated via the --ascii command-line flag or by setting the SQLCMDFORMAT variable to "ascii".
- Introduces ASCII table formatter with automatic column wrapping for wide result sets
- Updates the formatter initialization pattern across the codebase to support format selection
- Adds comprehensive test coverage for the new formatter
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/sqlcmd/variables.go | Adds "ascii" case handling in Format() method and initializes SQLCMDFORMAT variable |
| pkg/sqlcmd/format.go | Updates NewSQLCmdDefaultFormatter to accept Variables parameter and delegate to ASCII formatter when appropriate |
| pkg/sqlcmd/format_ascii.go | Implements new asciiFormatter with table rendering, column wrapping, and numeric alignment |
| pkg/sqlcmd/format_ascii_test.go | Provides test coverage for ASCII formatter including basic output and column wrapping scenarios |
| pkg/sqlcmd/sqlcmd_test.go | Updates test helper functions to pass Variables to formatter constructor |
| pkg/sqlcmd/commands_test.go | Updates TestListColorPrintsStyleSamples to pass Variables to formatter constructor |
| cmd/sqlcmd/sqlcmd.go | Adds --ascii flag definition and implements format variable setting logic |
| internal/sql/mssql.go | Updates formatter initialization to pass Variables parameter |
| build/buildfast.cmd | Adds Windows build script for faster development builds |
| README.md | Documents the new --ascii option and ASCII table format feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pkg/sqlcmd/format.go:101
- The
varsfield is not initialized in thesqlCmdFormatterTypestruct. This will cause a nil pointer dereference when methods likeScreenWidth()orColumnSeparator()are called onf.varsin the horizontal/vertical formatter. Addvars: vars,to fix this issue.
return &sqlCmdFormatterType{
removeTrailingSpaces: removeTrailingSpaces,
format: "horizontal",
colorizer: color.New(false),
ccb: ccb,
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
please resolve the comments that have been addressed |
…ed when using ASCII table format
All resolved. |
|
@shueybubbles There's still an issue: if a cell's content exceeds the terminal width, the output doesn't display well.
I can submit a new commit to limit the maximum column width to the terminal width and truncate any excess content. Any ideas? |

This pull request adds a new ASCII table output format to sqlcmd, making it easier to read query results. It introduces the
--asciicommand-line option and updates the relevant code paths to support this feature.README.mdhas also been updated to reflect this option.If
--asciiis not used, sqlcmd behaves exactly the same as before.The new output format looks like this: