mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-02 03:10:42 -05:00
cli output fix (#1221)
This commit is contained in:
+24
-1
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user