mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-15 02:52:55 -05:00
Small bug fixes for schema methods with nil schemas
This commit is contained in:
@@ -49,11 +49,11 @@ type RowDiffSource struct {
|
||||
|
||||
func NewRowDiffSource(ad RowDiffer, joiner *rowconv.Joiner, warnFn rowconv.WarnFunction) *RowDiffSource {
|
||||
return &RowDiffSource{
|
||||
ad,
|
||||
joiner,
|
||||
rowconv.IdentityConverter,
|
||||
rowconv.IdentityConverter,
|
||||
warnFn,
|
||||
ad: ad,
|
||||
joiner: joiner,
|
||||
oldRowConv: rowconv.IdentityConverter,
|
||||
newRowConv: rowconv.IdentityConverter,
|
||||
warnFn: warnFn,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,8 @@ func ExtractAllColNames(sch Schema) (map[uint64]string, error) {
|
||||
}
|
||||
|
||||
func IsKeyless(sch Schema) bool {
|
||||
return sch.GetPKCols().Size() == 0 &&
|
||||
return sch != nil &&
|
||||
sch.GetPKCols().Size() == 0 &&
|
||||
sch.GetAllCols().Size() != 0
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ var _ sql.RowIter = prollyDiffIter{}
|
||||
// schema of |from| to |targetFromSchema| and the schema of |to| to
|
||||
// |targetToSchema|. See the tablediff_prolly package.
|
||||
func newProllyDiffIter(ctx *sql.Context, dp DiffPartition, ddb *doltdb.DoltDB, targetFromSchema, targetToSchema schema.Schema) (prollyDiffIter, error) {
|
||||
if schema.IsKeyless(targetToSchema) {
|
||||
if schema.IsKeyless(targetToSchema) || schema.IsKeyless(targetFromSchema) {
|
||||
return prollyDiffIter{}, errors.New("diffs with keyless schema have not been implemented yet")
|
||||
}
|
||||
|
||||
|
||||
@@ -80,21 +80,23 @@ func TestSingleQuery(t *testing.T) {
|
||||
|
||||
// Convenience test for debugging a single query. Unskip and set to the desired query.
|
||||
func TestSingleScript(t *testing.T) {
|
||||
t.Skip()
|
||||
// t.Skip()
|
||||
|
||||
var scripts = []queries.ScriptTest{
|
||||
{
|
||||
Name: "table with commit column should maintain its data in diff",
|
||||
SetUpScript: []string{
|
||||
"CREATE TABLE t (pk int PRIMARY KEY, commit text);",
|
||||
"set @Commit1 = dolt_commit('-am', 'creating table t');",
|
||||
"INSERT INTO t VALUES (1, 'hi');",
|
||||
"set @Commit2 = dolt_commit('-am', 'insert data');",
|
||||
Name: "new table",
|
||||
SetUpScript: []string{
|
||||
"create table t1 (a int primary key, b int)",
|
||||
"insert into t1 values (1,2)",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_commit, from_pk, from_commit, diff_type from dolt_diff('t', @Commit1, @Commit2);",
|
||||
Expected: []sql.Row{{1, "hi", nil, nil, "added"}},
|
||||
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 from_a, from_b, from_commit, to_commit, diff_type from dolt_diff('t1', 'WORKING', 'HEAD')",
|
||||
Expected: []sql.Row{{1, 2, "WORKING", "HEAD", "removed"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user