cli output fix (#1221)

This commit is contained in:
Brian Hendriks
2021-01-19 10:26:58 -08:00
committed by GitHub
parent 5296812976
commit f64c0286a3
2 changed files with 30 additions and 7 deletions
+24 -1
View File
@@ -39,4 +39,27 @@ teardown() {
run dolt sql "SELECT * FROM test;"
[ $status -eq 1 ]
[[ "$output" =~ "Invalid Argument:" ]] || false
}
}
@test "validate string formatting" {
dolt sql <<SQL
CREATE TABLE test2 (
str varchar(256) NOT NULL,
PRIMARY KEY (str)
);
SQL
TESTSTR='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()){}[]/=?+|,.<>;:_-_%d%s%f'
dolt sql -q "INSERT INTO test2 (str) VALUES ('$TESTSTR')"
run dolt sql -q "SELECT * FROM test2"
[ $status -eq 0 ]
[[ "$output" =~ "$TESTSTR" ]] || false
run dolt sql -q "SELECT * FROM test2" -r csv
[ $status -eq 0 ]
[[ "$output" =~ "$TESTSTR" ]] || false
run dolt sql -q "SELECT * FROM test2" -r json
[ $status -eq 0 ]
[[ "$output" =~ "$TESTSTR" ]] || false
}
+6 -6
View File
@@ -129,7 +129,7 @@ func writeToCliOutStageFunc(ctx context.Context, items []pipeline.ItemWithProps)
for _, item := range items {
str := *item.GetItem().(*string)
cli.Printf(str)
cli.Print(str)
}
return nil, nil
@@ -279,20 +279,20 @@ func writeJSONToCliOutStageFunc(ctx context.Context, items []pipeline.ItemWithPr
if items == nil {
if hasRun {
cli.Printf("]}")
cli.Print("]}")
} else {
cli.Printf("{\"rows\":[]}")
cli.Print("{\"rows\":[]}")
}
} else {
for _, item := range items {
if hasRun {
cli.Printf(",")
cli.Print(",")
} else {
cli.Printf("{\"rows\": [")
cli.Print("{\"rows\": [")
}
str := *item.GetItem().(*string)
cli.Printf(str)
cli.Print(str)
hasRun = true
}