Skip to content

Conversation

@0x7FFFFFFFFFFFFFFF
Copy link

This pull request adds a new ASCII table output format to sqlcmd, making it easier to read query results. It introduces the --ascii command-line option and updates the relevant code paths to support this feature. README.md has also been updated to reflect this option.

If --ascii is not used, sqlcmd behaves exactly the same as before.

The new output format looks like this:

image

@shueybubbles shueybubbles requested a review from Copilot November 24, 2025 03:45
@shueybubbles
Copy link
Collaborator

thx for opening a PR!

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 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.

@shueybubbles
Copy link
Collaborator

func (a *SQLCmdArguments) Validate(c *cobra.Command) (err error) {

--vertical and --ascii should be marked as mutually exclusive


Refers to: cmd/sqlcmd/sqlcmd.go:132 in dcdaa09. [](commit_id = dcdaa09, deletion_comment = False)

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 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 vars field is not initialized in the sqlCmdFormatterType struct. This will cause a nil pointer dereference when methods like ScreenWidth() or ColumnSeparator() are called on f.vars in the horizontal/vertical formatter. Add vars: 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.

@shueybubbles
Copy link
Collaborator

please resolve the comments that have been addressed

@0x7FFFFFFFFFFFFFFF
Copy link
Author

please resolve the comments that have been addressed

All resolved.

@0x7FFFFFFFFFFFFFFF
Copy link
Author

0x7FFFFFFFFFFFFFFF commented Jan 31, 2026

@shueybubbles There's still an issue: if a cell's content exceeds the terminal width, the output doesn't display well.

image

I can submit a new commit to limit the maximum column width to the terminal width and truncate any excess content. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants