diff --git a/.circleci/config.yml b/.circleci/config.yml index 406a82e2..bf8d9288 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,8 +54,8 @@ jobs: - run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -cache=true -coverprofile=coverage5-2.txt -covermode=atomic - run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -coverprofile=coverage6-1.txt -covermode=atomic - run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -cache=true -coverprofile=coverage6-2.txt -covermode=atomic - - run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -coverprofile=coverage7-1.txt -covermode=atomic - - run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -cache=true -coverprofile=coverage7-2.txt -covermode=atomic + - run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true -coverprofile=coverage7-1.txt -covermode=atomic + - run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true -cache=true -coverprofile=coverage7-2.txt -covermode=atomic - run: gocovmerge coverage1-1.txt coverage1-2.txt coverage2-1.txt coverage2-2.txt coverage3-1.txt coverage3-2.txt coverage4-1.txt coverage4-2.txt coverage5-1.txt coverage5-2.txt coverage6-1.txt coverage6-2.txt coverage7-1.txt coverage7-2.txt > coverage.txt - run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/session_update_test.go b/session_update_test.go index 53fdd270..480fc5fc 100644 --- a/session_update_test.go +++ b/session_update_test.go @@ -110,7 +110,7 @@ func setupForUpdate(engine EngineInterface) error { } func TestForUpdate(t *testing.T) { - if testEngine.Dialect().DriverName() != "mysql" && testEngine.Dialect().DriverName() != "mymysql" { + if *ignoreSelectUpdate { return } diff --git a/test_tidb.sh b/test_tidb.sh index 6ecb50a2..03d2d6cd 100755 --- a/test_tidb.sh +++ b/test_tidb.sh @@ -1 +1 @@ -go test -db=mysql -conn_str="root:@tcp(localhost:4000)/xorm_test" \ No newline at end of file +go test -db=mysql -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true \ No newline at end of file diff --git a/xorm_test.go b/xorm_test.go index fe0a3519..a35f0743 100644 --- a/xorm_test.go +++ b/xorm_test.go @@ -26,14 +26,15 @@ var ( dbType string connString string - db = flag.String("db", "sqlite3", "the tested database") - showSQL = flag.Bool("show_sql", true, "show generated SQLs") - ptrConnStr = flag.String("conn_str", "./test.db?cache=shared&mode=rwc", "test database connection string") - mapType = flag.String("map_type", "snake", "indicate the name mapping") - cache = flag.Bool("cache", false, "if enable cache") - cluster = flag.Bool("cluster", false, "if this is a cluster") - splitter = flag.String("splitter", ";", "the splitter on connstr for cluster") - schema = flag.String("schema", "", "specify the schema") + db = flag.String("db", "sqlite3", "the tested database") + showSQL = flag.Bool("show_sql", true, "show generated SQLs") + ptrConnStr = flag.String("conn_str", "./test.db?cache=shared&mode=rwc", "test database connection string") + mapType = flag.String("map_type", "snake", "indicate the name mapping") + cache = flag.Bool("cache", false, "if enable cache") + cluster = flag.Bool("cluster", false, "if this is a cluster") + splitter = flag.String("splitter", ";", "the splitter on connstr for cluster") + schema = flag.String("schema", "", "specify the schema") + ignoreSelectUpdate = flag.Bool("ignore_select_update", false, "ignore select update if implementation difference, only for tidb") ) func createEngine(dbType, connStr string) error { @@ -51,6 +52,7 @@ func createEngine(dbType, connStr string) error { return fmt.Errorf("db.Exec: %v", err) } db.Close() + *ignoreSelectUpdate = true case core.POSTGRES: db, err := sql.Open(dbType, connStr) if err != nil { @@ -73,6 +75,7 @@ func createEngine(dbType, connStr string) error { } } db.Close() + *ignoreSelectUpdate = true case core.MYSQL: db, err := sql.Open(dbType, strings.Replace(connStr, "xorm_test", "mysql", -1)) if err != nil { @@ -82,11 +85,16 @@ func createEngine(dbType, connStr string) error { return fmt.Errorf("db.Exec: %v", err) } db.Close() + default: + *ignoreSelectUpdate = true } testEngine, err = NewEngine(dbType, connStr) } else { testEngine, err = NewEngineGroup(dbType, strings.Split(connStr, *splitter)) + if dbType != "mysql" && dbType != "mymysql" { + *ignoreSelectUpdate = true + } } if err != nil { return err