From 03ea5d7309b7df42845d88dd8c518f40d3832b59 Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Wed, 24 Aug 2022 13:56:54 -0700 Subject: [PATCH] fix Noms Map assumption in dolt ls --verbose --- go/cmd/dolt/commands/ls.go | 11 ++++++----- integration-tests/bats/1pk5col-ints.bats | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/go/cmd/dolt/commands/ls.go b/go/cmd/dolt/commands/ls.go index c6695146b5..fae751d76e 100644 --- a/go/cmd/dolt/commands/ls.go +++ b/go/cmd/dolt/commands/ls.go @@ -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 { diff --git a/integration-tests/bats/1pk5col-ints.bats b/integration-tests/bats/1pk5col-ints.bats index ae901e37e2..10c488247c 100755 --- a/integration-tests/bats/1pk5col-ints.bats +++ b/integration-tests/bats/1pk5col-ints.bats @@ -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