1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 23:00:55 +00:00

Orm: Add tidb for query builder

This commit is contained in:
ngaut 2015-09-11 11:24:58 +08:00
parent c73e0395ed
commit c841a77ad6
3 changed files with 7 additions and 4 deletions

View File

@ -397,7 +397,7 @@ go test -v github.com/astaxie/beego/orm
#### TiDB #### TiDB
export ORM_DRIVER=tidb export ORM_DRIVER=tidb
export ORM_SOURCE='memory://test' export ORM_SOURCE='memory://test/test'
go test -v github.com/astaxie/beego/orm go test -v github.com/astaxie/beego/orm
`) `)

View File

@ -26,6 +26,8 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/juju/errors"
) )
var _ = os.PathSeparator var _ = os.PathSeparator
@ -133,6 +135,7 @@ func throwFail(t *testing.T, err error, args ...interface{}) {
} }
con += " " + strings.Join(parts, ", ") con += " " + strings.Join(parts, ", ")
} }
t.Error(errors.ErrorStack(err))
t.Error(con) t.Error(con)
t.Fail() t.Fail()
} }
@ -172,7 +175,7 @@ func TestSyncDb(t *testing.T) {
RegisterModel(new(UserBig)) RegisterModel(new(UserBig))
RegisterModel(new(PostTags)) RegisterModel(new(PostTags))
err := RunSyncdb("default", true, false) err := RunSyncdb("default", true, true)
throwFail(t, err) throwFail(t, err)
modelCache.clean() modelCache.clean()

View File

@ -48,8 +48,8 @@ type QueryBuilder interface {
func NewQueryBuilder(driver string) (qb QueryBuilder, err error) { func NewQueryBuilder(driver string) (qb QueryBuilder, err error) {
if driver == "mysql" { if driver == "mysql" {
qb = new(MySQLQueryBuilder) qb = new(MySQLQueryBuilder)
} else if driver == "mysql" { } else if driver == "tidb" {
qb = new(MySQLQueryBuilder) qb = new(TiDBQueryBuilder)
} else if driver == "postgres" { } else if driver == "postgres" {
err = errors.New("postgres query builder is not supported yet") err = errors.New("postgres query builder is not supported yet")
} else if driver == "sqlite" { } else if driver == "sqlite" {