From 0e8ddd27253bbb050e3e4f2b5d4c768a15e01bf8 Mon Sep 17 00:00:00 2001 From: Nathan Gabrielson Date: Tue, 29 Jul 2025 14:58:25 -0700 Subject: [PATCH] Fix bad + more testing, safer type conversion --- go/cmd/dolt/commands/ci/view.go | 18 +++++++++++++++--- integration-tests/bats/ci.bats | 21 +++++++-------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/go/cmd/dolt/commands/ci/view.go b/go/cmd/dolt/commands/ci/view.go index 9b14b244bd..74ef7118d8 100644 --- a/go/cmd/dolt/commands/ci/view.go +++ b/go/cmd/dolt/commands/ci/view.go @@ -203,17 +203,29 @@ func getSavedQueries(sqlCtx *sql.Context, queryist cli.Queryist) (map[string]str return nil, err } for _, row := range rows { - queryName, err := row[2].(*val.TextStorage).Unwrap(sqlCtx) + var queryName, queryStatement string + queryName, err = getStringColAsString(sqlCtx, row[2]) if err != nil { return nil, err } - queryStatement, err := row[3].(*val.TextStorage).Unwrap(sqlCtx) + queryStatement, err := getStringColAsString(sqlCtx, row[3]) if err != nil { return nil, err } savedQueries[queryName] = queryStatement } } - return savedQueries, nil } + +// The dolt_query_catalog system table returns *val.TextStorage types under certain situations, +// so we use a special parser to get the correct string values +func getStringColAsString(sqlCtx *sql.Context, tableValue interface{}) (string, error) { + if ts, ok := tableValue.(*val.TextStorage); ok { + return ts.Unwrap(sqlCtx) + } else if str, ok := tableValue.(string); ok { + return str, nil + } else { + return "", fmt.Errorf("unexpected type %T, was expecting string", tableValue) + } +} diff --git a/integration-tests/bats/ci.bats b/integration-tests/bats/ci.bats index a48d55d6b3..4b2da642bc 100644 --- a/integration-tests/bats/ci.bats +++ b/integration-tests/bats/ci.bats @@ -10,12 +10,6 @@ teardown() { teardown_common } -skip_remote_engine() { - if [ "$SQL_ENGINE" = "remote-engine" ]; then - skip "session ctx in shell is not the same as session in server" - fi -} - get_commit_hash() { local logline=$(dolt log -n "$1") echo ${logline:12:32} @@ -355,9 +349,6 @@ EOF } @test "ci: dolt ci view shows ci" { - if [ "$SQL_ENGINE" = "remote-engine" ]; then - skip "Dolt sql --save has not been migrated to be used with an active server" - fi cat > workflow.yaml < workflow.yaml <