mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-20 19:38:55 -05:00
cleaning
This commit is contained in:
@@ -208,7 +208,6 @@ func (dt *DiffTable) PartitionRows(ctx *sql.Context, part sql.Partition) (sql.Ro
|
||||
return dp.GetRowIter(ctx, dt.ddb, dt.joiner, dt.lookup)
|
||||
}
|
||||
|
||||
// TODO: create new index type or use modified DoltIndexes?
|
||||
func (dt *DiffTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error) {
|
||||
return index.DoltDiffIndexesFromTable(ctx, "", dt.name, dt.table)
|
||||
}
|
||||
|
||||
@@ -1757,7 +1757,7 @@ var DiffSystemTableScriptTests = []queries.ScriptTest{
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "selecting to and from primary key columns",
|
||||
Name: "selecting to_pk columns",
|
||||
SetUpScript: []string{
|
||||
"create table t (pk int primary key, c1 int, c2 int);",
|
||||
"insert into t values (1, 2, 3), (4, 5, 6);",
|
||||
@@ -1786,10 +1786,42 @@ var DiffSystemTableScriptTests = []queries.ScriptTest{
|
||||
{7, 8, 9, nil, nil, nil, "added"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "selecting to_pk1 and to_pk2 columns",
|
||||
SetUpScript: []string{
|
||||
"create table t (pk1 int, pk2 int, c1 int, primary key (pk1, pk2));",
|
||||
"insert into t values (1, 2, 3), (4, 5, 6);",
|
||||
"set @Commit1 = (select DOLT_COMMIT('-am', 'first commit'));",
|
||||
"insert into t values (7, 8, 9);",
|
||||
"set @Commit2 = (select DOLT_COMMIT('-am', 'second commit'));",
|
||||
"update t set c1 = 0 where pk1 > 5;",
|
||||
"set @Commit3 = (select DOLT_COMMIT('-am', 'third commit'));",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT to_pk, to_c1, to_c2, from_pk, from_c1, from_c2, diff_type FROM DOLT_DIFF_t WHERE to_pk = 7 and from_pk = 7 ORDER BY to_pk;",
|
||||
Query: "SELECT COUNT(*) FROM DOLT_DIFF_t;",
|
||||
Expected: []sql.Row{{4}},
|
||||
},
|
||||
{
|
||||
Query: "SELECT to_pk1, to_pk2, to_c1, from_pk1, from_pk2, from_c1, diff_type FROM DOLT_DIFF_t WHERE to_pk1 = 1 ORDER BY to_pk1;",
|
||||
Expected: []sql.Row{
|
||||
{7, 0, 9, 7, 8, 9, "modified"},
|
||||
{1, 2, 3, nil, nil, nil, "added"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Query: "SELECT to_pk1, to_pk2, to_c1, from_pk1, from_pk2, from_c1, diff_type FROM DOLT_DIFF_t WHERE to_pk1 = 1 and to_pk2 = 2 ORDER BY to_pk1;",
|
||||
Expected: []sql.Row{
|
||||
{1, 2, 3, nil, nil, nil, "added"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Query: "SELECT to_pk1, to_pk2, to_c1, from_pk1, from_pk2, from_c1, diff_type FROM DOLT_DIFF_t WHERE to_pk1 > 1 and to_pk2 < 10 ORDER BY to_pk1;",
|
||||
Expected: []sql.Row{
|
||||
{4, 5, 6, nil, nil, nil, "added"},
|
||||
{7, 8, 0, 7, 8, 9, "modified"},
|
||||
{7, 8, 9, nil, nil, nil, "added"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -63,7 +63,7 @@ func DoltDiffIndexesFromTable(ctx context.Context, db, tbl string, t *doltdb.Tab
|
||||
toCols := make([]schema.Column, len(cols))
|
||||
for i, col := range cols {
|
||||
toCols[i] = col
|
||||
toCols[i].Name = "to_" + col.Name // TODO: const?
|
||||
toCols[i].Name = "to_" + col.Name
|
||||
}
|
||||
|
||||
// to_ columns
|
||||
@@ -80,21 +80,29 @@ func DoltDiffIndexesFromTable(ctx context.Context, db, tbl string, t *doltdb.Tab
|
||||
keyBld: keyBld,
|
||||
}
|
||||
|
||||
// TODO: from_ columns
|
||||
fromIndex := doltIndex{
|
||||
id: "PRIMARY",
|
||||
tblName: doltdb.DoltDiffTablePrefix + tbl,
|
||||
dbName: db,
|
||||
columns: cols,
|
||||
indexSch: sch,
|
||||
tableSch: sch,
|
||||
unique: true,
|
||||
comment: "",
|
||||
vrw: t.ValueReadWriter(),
|
||||
keyBld: keyBld,
|
||||
}
|
||||
// TODO: need to add from_ columns
|
||||
//// add from_ prefix
|
||||
//fromCols := make([]schema.Column, len(cols))
|
||||
//for i, col := range cols {
|
||||
// toCols[i] = col
|
||||
// toCols[i].Name = "from_" + col.Name
|
||||
//}
|
||||
//
|
||||
//// from_ columns
|
||||
//fromIndex := doltIndex{
|
||||
// id: "PRIMARY",
|
||||
// tblName: doltdb.DoltDiffTablePrefix + tbl,
|
||||
// dbName: db,
|
||||
// columns: fromCols,
|
||||
// indexSch: sch,
|
||||
// tableSch: sch,
|
||||
// unique: true,
|
||||
// comment: "",
|
||||
// vrw: t.ValueReadWriter(),
|
||||
// keyBld: keyBld,
|
||||
//}
|
||||
|
||||
return append(indexes, toIndex, fromIndex), nil
|
||||
return append(indexes, toIndex), nil
|
||||
}
|
||||
|
||||
func DoltIndexesFromTable(ctx context.Context, db, tbl string, t *doltdb.Table) (indexes []sql.Index, err error) {
|
||||
|
||||
Reference in New Issue
Block a user