mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-31 00:50:14 -06:00
Fix dolt_clean for doltgres
This commit is contained in:
11
go/libraries/doltcore/env/actions/reset.go
vendored
11
go/libraries/doltcore/env/actions/reset.go
vendored
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/env"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
|
||||
"github.com/dolthub/dolt/go/store/datas"
|
||||
)
|
||||
|
||||
@@ -271,7 +272,7 @@ func getUnionedTables(ctx context.Context, tables []doltdb.TableName, stagedRoot
|
||||
|
||||
// CleanUntracked deletes untracked tables from the working root.
|
||||
// Evaluates untracked tables as: all working tables - all staged tables.
|
||||
func CleanUntracked(ctx context.Context, roots doltdb.Roots, tables []string, dryrun bool, force bool) (doltdb.Roots, error) {
|
||||
func CleanUntracked(ctx *sql.Context, roots doltdb.Roots, tables []string, dryrun bool, force bool) (doltdb.Roots, error) {
|
||||
untrackedTables := make(map[doltdb.TableName]struct{})
|
||||
|
||||
var err error
|
||||
@@ -284,21 +285,21 @@ func CleanUntracked(ctx context.Context, roots doltdb.Roots, tables []string, dr
|
||||
|
||||
for i := range tables {
|
||||
name := tables[i]
|
||||
_, _, err = roots.Working.GetTable(ctx, doltdb.TableName{Name: name})
|
||||
resolvedName, _, _, err := resolve.Table(ctx, roots.Working, name)
|
||||
if err != nil {
|
||||
return doltdb.Roots{}, err
|
||||
}
|
||||
untrackedTables[doltdb.TableName{Name: name}] = struct{}{}
|
||||
untrackedTables[resolvedName] = struct{}{}
|
||||
}
|
||||
|
||||
// untracked tables = working tables - staged tables
|
||||
headTblNames, err := roots.Staged.GetTableNames(ctx, doltdb.DefaultSchemaName)
|
||||
headTblNames := GetAllTableNames(ctx, roots.Staged)
|
||||
if err != nil {
|
||||
return doltdb.Roots{}, err
|
||||
}
|
||||
|
||||
for _, name := range headTblNames {
|
||||
delete(untrackedTables, doltdb.TableName{Name: name})
|
||||
delete(untrackedTables, name)
|
||||
}
|
||||
|
||||
newRoot := roots.Working
|
||||
|
||||
Reference in New Issue
Block a user