提交 caf32e9e 编写于 作者: martianzhang's avatar martianzhang

run all test single pass

not fix too many connections yet
上级 019ee551
......@@ -309,7 +309,7 @@ func (idxAdv *IndexAdvisor) RuleImplicitConversion() Rule {
// 列与值比较
for _, val := range values {
if colList[0].DataType == "" {
common.Log.Debug("Can't get %s data type", colList[0].Name)
common.Log.Warn("Can't get %s data type", colList[0].Name)
break
}
......
......@@ -357,8 +357,9 @@ func TestIndexAdvise(t *testing.T) {
}
func TestIndexAdviseNoEnv(t *testing.T) {
common.Config.OnlineDSN.Disable = true
common.Log.Debug("Entering function: %s", common.GetFunctionName())
orgOnlineDSNStatus := common.Config.OnlineDSN.Disable
common.Config.OnlineDSN.Disable = true
vEnv, rEnv := env.BuildEnv()
defer vEnv.CleanUp()
......@@ -384,6 +385,7 @@ func TestIndexAdviseNoEnv(t *testing.T) {
}
}
}
common.Config.OnlineDSN.Disable = orgOnlineDSNStatus
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
}
......
......@@ -25,6 +25,7 @@ import (
)
func TestRewrite(t *testing.T) {
orgTestDSNStatus := common.Config.TestDSN.Disable
common.Config.TestDSN.Disable = false
testSQL := []map[string]string{
{
......@@ -97,9 +98,11 @@ func TestRewrite(t *testing.T) {
t.Errorf("want: %s\ngot: %s", sql["output"], rw.NewSQL)
}
}
common.Config.TestDSN.Disable = orgTestDSNStatus
}
func TestRewriteStar2Columns(t *testing.T) {
orgTestDSNStatus := common.Config.TestDSN.Disable
common.Config.TestDSN.Disable = false
testSQL := []map[string]string{
{
......@@ -127,6 +130,7 @@ func TestRewriteStar2Columns(t *testing.T) {
t.Errorf("want: %s\ngot: %s", sql["output"], rw.NewSQL)
}
}
common.Config.TestDSN.Disable = orgTestDSNStatus
}
func TestRewriteInsertColumns(t *testing.T) {
......@@ -427,6 +431,7 @@ func TestRewriteAlwaysTrue(t *testing.T) {
// TODO:
func TestRewriteSubQuery2Join(t *testing.T) {
orgTestDSNStatus := common.Config.TestDSN.Disable
common.Config.TestDSN.Disable = true
testSQL := []map[string]string{
{
......@@ -452,6 +457,7 @@ func TestRewriteSubQuery2Join(t *testing.T) {
t.Errorf("want: %s\ngot: %s", sql["output"], rw.NewSQL)
}
}
common.Config.TestDSN.Disable = orgTestDSNStatus
}
func TestRewriteDML2Select(t *testing.T) {
......
......@@ -371,7 +371,8 @@ func (td TableDesc) Columns() []string {
// showCreate show create
func (db *Connector) showCreate(createType, name string) (string, error) {
// 执行 show create table
// 执行 show create table|database
// createType = [table|database]
res, err := db.Query(fmt.Sprintf("show create %s `%s`", createType, name))
if err != nil {
return "", err
......@@ -461,14 +462,17 @@ func (db *Connector) FindColumn(name, dbName string, tables ...string) ([]*commo
var col common.Column
for res.Rows.Next() {
var character, collation string
res.Rows.Scan(&col.Table,
var character, collation []byte
res.Rows.Scan(
&col.Table,
&col.DB,
&col.DataType,
&character,
&collation)
col.Character = character
col.Collation = collation
&collation,
)
col.Name = name
col.Character = string(character)
col.Collation = string(collation)
// 填充字符集和排序规则
if col.Character == "" {
// 当从`INFORMATION_SCHEMA`.`COLUMNS`表中查询不到相关列的character和collation的信息时
......
[]*common.Column{
&common.Column{
Name: "",
Name: "film_id",
Alias: nil,
Table: "film",
DB: "sakila",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册