Fix merge issues and more tests

This commit is contained in:
Zach Musgrave
2022-06-17 16:05:36 -07:00
parent 044ff2747e
commit 79682eddd1
3 changed files with 32 additions and 18 deletions

View File

@@ -17,7 +17,7 @@ package commands
import (
"context"
"fmt"
"reflect"
"io"
"sort"
"strings"
@@ -444,13 +444,12 @@ func newSqlEngine(ctx context.Context, dEnv *env.DoltEnv) (*engine.SqlEngine, er
ctx,
mrEnv,
engine.FormatCsv,
dbName,
false,
"",
"",
"root",
"",
false,
&engine.SqlEngineConfig{
InitialDb: dbName,
IsReadOnly: false,
ServerUser: "root",
Autocommit: false,
},
)
}

View File

@@ -526,18 +526,25 @@ func GetDiffTableSchemaAndJoiner(format *types.NomsBinFormat, fromSch, toSch sch
return nil, nil, err
}
} else {
colCollection := toSch.GetAllCols()
colCollection = colCollection.Append(
schema.NewColumn("commit", schema.DiffCommitTag, types.StringKind, false),
schema.NewColumn("commit_date", schema.DiffCommitDateTag, types.TimestampKind, false))
toSch = schema.MustSchemaFromCols(colCollection)
colCollection = fromSch.GetAllCols()
colCollection := schema.NewColCollection()
if fromSch != nil {
colCollection = fromSch.GetAllCols()
}
colCollection = colCollection.Append(
schema.NewColumn("commit", schema.DiffCommitTag, types.StringKind, false),
schema.NewColumn("commit_date", schema.DiffCommitDateTag, types.TimestampKind, false))
fromSch = schema.MustSchemaFromCols(colCollection)
colCollection = schema.NewColCollection()
if toSch != nil {
colCollection = toSch.GetAllCols()
}
colCollection = colCollection.Append(
schema.NewColumn("commit", schema.DiffCommitTag, types.StringKind, false),
schema.NewColumn("commit_date", schema.DiffCommitDateTag, types.TimestampKind, false))
toSch = schema.MustSchemaFromCols(colCollection)
j, err = rowconv.NewJoiner(
[]rowconv.NamedSchema{{Name: diff.To, Sch: toSch}, {Name: diff.From, Sch: fromSch}},
map[string]rowconv.ColNamingFunc{

View File

@@ -2992,12 +2992,20 @@ var DiffTableFunctionScriptTests = []queries.ScriptTest{
Name: "new table",
SetUpScript: []string{
"create table t1 (a int primary key, b int)",
"insert into t1 values (1,1)",
"insert into t1 values (1,2)",
},
Assertions: []queries.ScriptTestAssertion{
Assertions: []queries.ScriptTestAssertion{
{
Query: "select * from dolt_diff",
Expected: nil,
Query: "select to_a, to_b, from_commit, to_commit, diff_type from dolt_diff('t1', 'HEAD', 'WORKING')",
Expected: []sql.Row{{1, 2, "HEAD", "WORKING", "added"}},
},
{
Query: "select to_a, from_b, from_commit, to_commit, diff_type from dolt_diff('t1', 'HEAD', 'WORKING')",
ExpectedErr: sql.ErrColumnNotFound,
},
{
Query: "select from_a, from_b, from_commit, to_commit, diff_type from dolt_diff('t1', 'WORKING', 'HEAD')",
Expected: []sql.Row{{1, 2, "WORKING", "HEAD", "removed"}},
},
},
},