fix Noms Map assumption in dolt ls --verbose

This commit is contained in:
Andy Arthur
2022-08-24 13:56:54 -07:00
parent c6884d4c07
commit 03ea5d7309
2 changed files with 10 additions and 5 deletions

View File

@@ -172,24 +172,25 @@ func printUserTables(ctx context.Context, root *doltdb.RootValue, label string,
func listTableVerbose(ctx context.Context, tbl string, root *doltdb.RootValue) (string, errhand.VerboseError) {
h, _, err := root.GetTableHash(ctx, tbl)
if err != nil {
return "", errhand.BuildDError("error: failed to get table hash").AddCause(err).Build()
}
tblVal, _, err := root.GetTable(ctx, tbl)
if err != nil {
return "", errhand.BuildDError("error: failed to get table").AddCause(err).Build()
}
rows, err := tblVal.GetNomsRowData(ctx)
rows, err := tblVal.GetRowData(ctx)
if err != nil {
return "", errhand.BuildDError("error: failed to get row data").AddCause(err).Build()
}
cnt, err := rows.Count()
if err != nil {
return "", errhand.VerboseErrorFromError(err)
}
return fmt.Sprintf("\t%-32s %s %d rows\n", tbl, h.String(), rows.Len()), nil
return fmt.Sprintf("\t%-32s %s %d rows\n", tbl, h.String(), cnt), nil
}
func printSystemTables(ctx context.Context, root *doltdb.RootValue, ddb *doltdb.DoltDB, verbose bool) errhand.VerboseError {

View File

@@ -27,6 +27,10 @@ teardown() {
run dolt ls
[ "$status" -eq 0 ]
[[ "${lines[1]}" =~ "test" ]] || false
run dolt ls --verbose
[ "$status" -eq 0 ]
[[ "${lines[1]}" =~ "0 rows" ]] || false
run dolt sql -q "select * from test"
[ "$status" -eq 0 ]
[[ "$output" =~ pk[[:space:]]+\|[[:space:]]+c1[[:space:]]+\|[[:space:]]+c2[[:space:]]+\|[[:space:]]+c3[[:space:]]+\|[[:space:]]+c4[[:space:]]+\|[[:space:]]+c5 ]] || false