-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
cli: conditionally output unicode characters in the output of sql -e #7048
Conversation
Reviewed 12 of 12 files at r1. sql/show.go, line 118 [r1] (raw file):
👎 on this - if tablewriter does the wrong thing with tabs, can we report it upstream? Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. sql/show.go, line 118 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. sql/show.go, line 118 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. sql/show.go, line 118 [r1] (raw file):
|
|
Summary: - by default, `sql -e` always escapes strings that contain special characters. It also forcefully escapes strings containing double quotes and backslashes, so as to ease automated processing by other languages (ie. a string starting with a doublequote character in the output will always be the start of an escaped string.). This way issue cockroachdb#4315 is still addressed adequately. - a new flag `--pretty` is added to the `sql` sub-command, to print row data as pretty-formatted ASCII art tables. - when results are pretty-formatted (either in the interactive shell or with `sql --pretty -e`), graphic unicode and newline characters are printed without escaping. This keeps the fix to cockroachdb#6926. - new tests are added in `cli_test.go` (`Example_sql_escape`) to test escaped and non-escaped output when table and column names contain special characters. - the `cli` API renames `runPrettyQuery` to `runQueryAndFormatResults`, and extends it with an extra argument to specify pretty-printing. (See issues/PRs cockroachdb#7045, cockroachdb#6926, cockroachdb#4354 and cockroachdb#4315 for background discussion.)
TFYR!
|
Reviewed 1 of 1 files at r3. Comments from Reviewable |
|
Docs updated with cockroachdb/docs#373. |
Summary:
sql -e
always escapes strings that contain specialcharacters. It also forcefully escapes strings containing double
quotes and backslashes, so as to ease automated processing by other
languages (ie. a string starting with a doublequote character in the
output will always be the start of an escaped string.). This
way issue cli: weirdness in SQL shell when printing a row #4315 is still addressed adequately.
--pretty
is added to thesql
sub-command, to printrow data as pretty-formatted ASCII art tables.
or with
sql --pretty -e
), graphic unicode and newline charactersare printed without escaping. This keeps the fix to cli: printing of strings containing newlines in cli #6926.
cli_test.go
(Example_sql_escape
) to testescaped and non-escaped output when table and column names contain
special characters.
cli
API renamesrunPrettyQuery
torunQueryAndFormatResults
, and extends it with an extra argument tospecify pretty-printing.
(See issues/PRs #7045, #6926, #4354 and #4315 for background discussion.)
cc @bdarnell @mjibson @dt
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)