mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 09:30:56 +00:00
Merge branch 'develop' into feature/support-begintx
This commit is contained in:
commit
5acc56648d
@ -2,7 +2,7 @@ language: go
|
|||||||
|
|
||||||
go:
|
go:
|
||||||
- "1.9.2"
|
- "1.9.2"
|
||||||
- "1.10.2"
|
- "1.10.3"
|
||||||
services:
|
services:
|
||||||
- redis-server
|
- redis-server
|
||||||
- mysql
|
- mysql
|
||||||
|
4
app.go
4
app.go
@ -117,7 +117,7 @@ func (app *App) Run(mws ...MiddleWare) {
|
|||||||
app.Server.Addr = httpsAddr
|
app.Server.Addr = httpsAddr
|
||||||
if BConfig.Listen.EnableHTTPS || BConfig.Listen.EnableMutualHTTPS {
|
if BConfig.Listen.EnableHTTPS || BConfig.Listen.EnableMutualHTTPS {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(20 * time.Microsecond)
|
time.Sleep(1000 * time.Microsecond)
|
||||||
if BConfig.Listen.HTTPSPort != 0 {
|
if BConfig.Listen.HTTPSPort != 0 {
|
||||||
httpsAddr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort)
|
httpsAddr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort)
|
||||||
app.Server.Addr = httpsAddr
|
app.Server.Addr = httpsAddr
|
||||||
@ -163,7 +163,7 @@ func (app *App) Run(mws ...MiddleWare) {
|
|||||||
// run normal mode
|
// run normal mode
|
||||||
if BConfig.Listen.EnableHTTPS || BConfig.Listen.EnableMutualHTTPS {
|
if BConfig.Listen.EnableHTTPS || BConfig.Listen.EnableMutualHTTPS {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(20 * time.Microsecond)
|
time.Sleep(1000 * time.Microsecond)
|
||||||
if BConfig.Listen.HTTPSPort != 0 {
|
if BConfig.Listen.HTTPSPort != 0 {
|
||||||
app.Server.Addr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort)
|
app.Server.Addr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort)
|
||||||
} else if BConfig.Listen.EnableHTTP {
|
} else if BConfig.Listen.EnableHTTP {
|
||||||
|
@ -75,7 +75,8 @@ func addModelFields(mi *modelInfo, ind reflect.Value, mName string, index []int)
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
//record current field index
|
//record current field index
|
||||||
fi.fieldIndex = append(index, i)
|
fi.fieldIndex = append(fi.fieldIndex, index...)
|
||||||
|
fi.fieldIndex = append(fi.fieldIndex, i)
|
||||||
fi.mi = mi
|
fi.mi = mi
|
||||||
fi.inModel = true
|
fi.inModel = true
|
||||||
if !mi.fields.Add(fi) {
|
if !mi.fields.Add(fi) {
|
||||||
|
@ -433,51 +433,57 @@ var (
|
|||||||
dDbBaser dbBaser
|
dDbBaser dbBaser
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
helpinfo = `need driver and source!
|
||||||
|
|
||||||
|
Default DB Drivers.
|
||||||
|
|
||||||
|
driver: url
|
||||||
|
mysql: https://github.com/go-sql-driver/mysql
|
||||||
|
sqlite3: https://github.com/mattn/go-sqlite3
|
||||||
|
postgres: https://github.com/lib/pq
|
||||||
|
tidb: https://github.com/pingcap/tidb
|
||||||
|
|
||||||
|
usage:
|
||||||
|
|
||||||
|
go get -u github.com/astaxie/beego/orm
|
||||||
|
go get -u github.com/go-sql-driver/mysql
|
||||||
|
go get -u github.com/mattn/go-sqlite3
|
||||||
|
go get -u github.com/lib/pq
|
||||||
|
go get -u github.com/pingcap/tidb
|
||||||
|
|
||||||
|
#### MySQL
|
||||||
|
mysql -u root -e 'create database orm_test;'
|
||||||
|
export ORM_DRIVER=mysql
|
||||||
|
export ORM_SOURCE="root:@/orm_test?charset=utf8"
|
||||||
|
go test -v github.com/astaxie/beego/orm
|
||||||
|
|
||||||
|
|
||||||
|
#### Sqlite3
|
||||||
|
export ORM_DRIVER=sqlite3
|
||||||
|
export ORM_SOURCE='file:memory_test?mode=memory'
|
||||||
|
go test -v github.com/astaxie/beego/orm
|
||||||
|
|
||||||
|
|
||||||
|
#### PostgreSQL
|
||||||
|
psql -c 'create database orm_test;' -U postgres
|
||||||
|
export ORM_DRIVER=postgres
|
||||||
|
export ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable"
|
||||||
|
go test -v github.com/astaxie/beego/orm
|
||||||
|
|
||||||
|
#### TiDB
|
||||||
|
export ORM_DRIVER=tidb
|
||||||
|
export ORM_SOURCE='memory://test/test'
|
||||||
|
go test -v github.com/astaxie/beego/orm
|
||||||
|
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Debug, _ = StrTo(DBARGS.Debug).Bool()
|
Debug, _ = StrTo(DBARGS.Debug).Bool()
|
||||||
|
|
||||||
if DBARGS.Driver == "" || DBARGS.Source == "" {
|
if DBARGS.Driver == "" || DBARGS.Source == "" {
|
||||||
fmt.Println(`need driver and source!
|
fmt.Println(helpinfo)
|
||||||
|
|
||||||
Default DB Drivers.
|
|
||||||
|
|
||||||
driver: url
|
|
||||||
mysql: https://github.com/go-sql-driver/mysql
|
|
||||||
sqlite3: https://github.com/mattn/go-sqlite3
|
|
||||||
postgres: https://github.com/lib/pq
|
|
||||||
tidb: https://github.com/pingcap/tidb
|
|
||||||
|
|
||||||
usage:
|
|
||||||
|
|
||||||
go get -u github.com/astaxie/beego/orm
|
|
||||||
go get -u github.com/go-sql-driver/mysql
|
|
||||||
go get -u github.com/mattn/go-sqlite3
|
|
||||||
go get -u github.com/lib/pq
|
|
||||||
go get -u github.com/pingcap/tidb
|
|
||||||
|
|
||||||
#### MySQL
|
|
||||||
mysql -u root -e 'create database orm_test;'
|
|
||||||
export ORM_DRIVER=mysql
|
|
||||||
export ORM_SOURCE="root:@/orm_test?charset=utf8"
|
|
||||||
go test -v github.com/astaxie/beego/orm
|
|
||||||
|
|
||||||
|
|
||||||
#### Sqlite3
|
|
||||||
export ORM_DRIVER=sqlite3
|
|
||||||
export ORM_SOURCE='file:memory_test?mode=memory'
|
|
||||||
go test -v github.com/astaxie/beego/orm
|
|
||||||
|
|
||||||
|
|
||||||
#### PostgreSQL
|
|
||||||
psql -c 'create database orm_test;' -U postgres
|
|
||||||
export ORM_DRIVER=postgres
|
|
||||||
export ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable"
|
|
||||||
go test -v github.com/astaxie/beego/orm
|
|
||||||
|
|
||||||
#### TiDB
|
|
||||||
export ORM_DRIVER=tidb
|
|
||||||
export ORM_SOURCE='memory://test/test'
|
|
||||||
go test -v github.com/astaxie/beego/orm`)
|
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,13 +1011,13 @@ func TestAll(t *testing.T) {
|
|||||||
|
|
||||||
qs = dORM.QueryTable("user")
|
qs = dORM.QueryTable("user")
|
||||||
num, err = qs.Filter("user_name", "nothing").All(&users)
|
num, err = qs.Filter("user_name", "nothing").All(&users)
|
||||||
throwFail(t, AssertIs(err, ErrNoRows))
|
throwFailNow(t, AssertIs(err, ErrNoRows))
|
||||||
throwFailNow(t, AssertIs(num, 0))
|
throwFailNow(t, AssertIs(num, 0))
|
||||||
|
|
||||||
var users3 []*User
|
var users3 []*User
|
||||||
qs = dORM.QueryTable("user")
|
qs = dORM.QueryTable("user")
|
||||||
num, err = qs.Filter("user_name", "nothing").All(&users3)
|
num, err = qs.Filter("user_name", "nothing").All(&users3)
|
||||||
throwFail(t, AssertIs(err, ErrNoRows))
|
throwFailNow(t, AssertIs(err, ErrNoRows))
|
||||||
throwFailNow(t, AssertIs(num, 0))
|
throwFailNow(t, AssertIs(num, 0))
|
||||||
throwFailNow(t, AssertIs(users3 == nil, false))
|
throwFailNow(t, AssertIs(users3 == nil, false))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user