Somewhat hacky fix to get commit hash qualified DBs working

This commit is contained in:
Zach Musgrave
2021-07-28 11:42:07 -07:00
parent 2938edeeb5
commit 56f7ea3661
2 changed files with 18 additions and 1 deletions

View File

@@ -1036,6 +1036,23 @@ func (sess *Session) AddDB(ctx *sql.Context, dbState InitialDbState) error {
if err != nil {
return err
}
} else {
headRoot, err := dbState.HeadCommit.GetRootValue()
if err != nil {
return err
}
hash, err := headRoot.HashOf()
if err != nil {
return err
}
err = sess.Session.SetSessionVariable(ctx, WorkingKey(db.Name()), hash.String())
if err != nil {
return err
}
sessionState.headRoot = headRoot
}
// This has to happen after SetRoot above, since it does a stale check before its work

View File

@@ -606,7 +606,7 @@ SQL
# get the second to last commit hash
hash=`dolt log | grep commit | cut -d" " -f2 | tail -n+2 | head -n1`
dolt sql -q "select * from \`dolt_repo_$$/$hash\`.a1 order by x;" -r csv
run dolt sql -q "select * from \`dolt_repo_$$/$hash\`.a1 order by x;" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 4 ]
}