mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-24 11:39:03 -05:00
dolt_diff respects qualified database
This commit is contained in:
@@ -425,7 +425,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
|
||||
}
|
||||
}
|
||||
|
||||
dt, found = dtables.NewUnscopedDiffTable(ctx, db.ddb, head), true
|
||||
dt, found = dtables.NewUnscopedDiffTable(ctx, db.ddb, db.name, head), true
|
||||
case doltdb.TableOfTablesInConflictName:
|
||||
dt, found = dtables.NewTableOfTablesInConflict(ctx, db.name, db.ddb), true
|
||||
case doltdb.TableOfTablesWithViolationsName:
|
||||
|
||||
@@ -46,6 +46,7 @@ var _ sql.FilteredTable = (*UnscopedDiffTable)(nil)
|
||||
// changed in each commit, across all branches.
|
||||
type UnscopedDiffTable struct {
|
||||
ddb *doltdb.DoltDB
|
||||
dbName string
|
||||
head *doltdb.Commit
|
||||
partitionFilters []sql.Expression
|
||||
commitCheck doltdb.CommitFilter
|
||||
@@ -60,8 +61,8 @@ type tableChange struct {
|
||||
}
|
||||
|
||||
// NewUnscopedDiffTable creates an UnscopedDiffTable
|
||||
func NewUnscopedDiffTable(_ *sql.Context, ddb *doltdb.DoltDB, head *doltdb.Commit) sql.Table {
|
||||
return &UnscopedDiffTable{ddb: ddb, head: head}
|
||||
func NewUnscopedDiffTable(_ *sql.Context, ddb *doltdb.DoltDB, dbName string, head *doltdb.Commit) sql.Table {
|
||||
return &UnscopedDiffTable{ddb: ddb, dbName: dbName, head: head}
|
||||
}
|
||||
|
||||
// Filters returns the list of filters that are applied to this table.
|
||||
@@ -192,9 +193,9 @@ func (dt *UnscopedDiffTable) LookupPartitions(ctx *sql.Context, lookup sql.Index
|
||||
|
||||
func (dt *UnscopedDiffTable) newWorkingSetRowItr(ctx *sql.Context) (sql.RowIter, error) {
|
||||
sess := dsess.DSessFromSess(ctx.Session)
|
||||
roots, ok := sess.GetRoots(ctx, ctx.GetCurrentDatabase())
|
||||
roots, ok := sess.GetRoots(ctx, dt.dbName)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unable to lookup roots for database %s", ctx.GetCurrentDatabase())
|
||||
return nil, fmt.Errorf("unable to lookup roots for database %s", dt.dbName)
|
||||
}
|
||||
|
||||
staged, unstaged, err := diff.GetStagedUnstagedTableDeltas(ctx, roots)
|
||||
|
||||
@@ -2581,6 +2581,22 @@ SQL
|
||||
[[ "$output" =~ "3" ]] || false
|
||||
}
|
||||
|
||||
@test "sql: dolt diff table respects qualified database" {
|
||||
dolt sql -q "CREATE DATABASE db01; CREATE DATABASE db02;"
|
||||
dolt sql -q "USE db01; CREATE TABLE t01(pk int primary key);"
|
||||
run dolt sql -q "USE db01; SELECT * FROM dolt_diff;"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "t01" ]] || false
|
||||
|
||||
run dolt sql -q "USE db02; SELECT * FROM dolt_diff;"
|
||||
[ "$status" -eq 0 ]
|
||||
! [[ "$output" =~ "t01" ]] || false
|
||||
|
||||
run dolt sql -q "USE db02; SELECT * FROM db01.dolt_diff;"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "t01" ]] || false
|
||||
}
|
||||
|
||||
@test "sql: sql print on order by returns the correct result" {
|
||||
dolt sql -q "CREATE TABLE mytable(pk int primary key);"
|
||||
dolt sql -q "INSERT INTO mytable VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20)"
|
||||
|
||||
Reference in New Issue
Block a user