Integrated tidb dialect

This commit is contained in:
Thomas Boerger 2016-09-13 11:18:12 +02:00 committed by Thomas Boerger
parent 041cd3dd31
commit f331b90c04
No known key found for this signature in database
GPG Key ID: 5A388F55283960B6
5 changed files with 27 additions and 2 deletions

13
dialect_tidb.go Normal file
View File

@ -0,0 +1,13 @@
package gorm
type tidb struct {
mysql
}
func init() {
RegisterDialect("tidb", &tidb{})
}
func (tidb) GetName() string {
return "tidb"
}

3
dialects/tidb/tidb.go Normal file
View File

@ -0,0 +1,3 @@
package tidb
import _ "github.com/pingcap/tidb"

View File

@ -17,6 +17,7 @@ import (
_ "github.com/jinzhu/gorm/dialects/mysql"
"github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/jinzhu/gorm/dialects/sqlite"
_ "github.com/jinzhu/gorm/dialects/tidb"
"github.com/jinzhu/now"
)
@ -60,6 +61,9 @@ func OpenTestConnection() (db *gorm.DB, err error) {
case "mssql":
fmt.Println("testing mssql...")
db, err = gorm.Open("mssql", "server=SERVER_HERE;database=rogue;user id=USER_HERE;password=PW_HERE;port=1433")
case "tidb":
fmt.Println("testing tidb...")
db, err = gorm.Open("tidb", filepath.Join(os.TempDir(), "goleveldb://gorm"))
default:
fmt.Println("testing sqlite3...")
db, err = gorm.Open("sqlite3", filepath.Join(os.TempDir(), "gorm.db"))

View File

@ -1,4 +1,4 @@
dialects=("postgres" "mysql" "sqlite")
dialects=("postgres" "mysql" "sqlite", "tidb")
for dialect in "${dialects[@]}" ; do
GORM_DIALECT=${dialect} go test

View File

@ -40,7 +40,12 @@ build:
- script:
name: test sqlite
code: |
go test ./...
GORM_DIALECT=sqlite3 go test ./...
- script:
name: test tidb
code: |
GORM_DIALECT=tidb go test ./...
- script:
name: test mysql