mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 22:51:29 +00:00
fix db locked
This commit is contained in:
parent
383a04f4c2
commit
61c0b3e286
10
orm/db.go
10
orm/db.go
@ -486,6 +486,8 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
|
|||||||
rs = r
|
rs = r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rs.Close()
|
||||||
|
|
||||||
var ref interface{}
|
var ref interface{}
|
||||||
|
|
||||||
args = make([]interface{}, 0)
|
args = make([]interface{}, 0)
|
||||||
@ -640,6 +642,8 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
|
|||||||
refs[i] = &ref
|
refs[i] = &ref
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rs.Close()
|
||||||
|
|
||||||
slice := ind
|
slice := ind
|
||||||
|
|
||||||
var cnt int64
|
var cnt int64
|
||||||
@ -1150,6 +1154,8 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
|
|||||||
refs[i] = &ref
|
refs[i] = &ref
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rs.Close()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cnt int64
|
cnt int64
|
||||||
columns []string
|
columns []string
|
||||||
@ -1268,6 +1274,8 @@ func (d *dbBase) GetTables(db dbQuerier) (map[string]bool, error) {
|
|||||||
return tables, err
|
return tables, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var table string
|
var table string
|
||||||
err := rows.Scan(&table)
|
err := rows.Scan(&table)
|
||||||
@ -1290,6 +1298,8 @@ func (d *dbBase) GetColumns(db dbQuerier, table string) (map[string][3]string, e
|
|||||||
return columns, err
|
return columns, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
name string
|
name string
|
||||||
|
@ -285,6 +285,8 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
if rows.Next() {
|
if rows.Next() {
|
||||||
if structMode {
|
if structMode {
|
||||||
columns, err := rows.Columns()
|
columns, err := rows.Columns()
|
||||||
@ -408,11 +410,12 @@ func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nInds := make([]reflect.Value, len(sInds))
|
defer rows.Close()
|
||||||
|
|
||||||
sInd := sInds[0]
|
|
||||||
|
|
||||||
var cnt int64
|
var cnt int64
|
||||||
|
nInds := make([]reflect.Value, len(sInds))
|
||||||
|
sInd := sInds[0]
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
|
||||||
if structMode {
|
if structMode {
|
||||||
@ -538,6 +541,8 @@ func (o *rawSet) readValues(container interface{}) (int64, error) {
|
|||||||
rs = r
|
rs = r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rs.Close()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
refs []interface{}
|
refs []interface{}
|
||||||
cnt int64
|
cnt int64
|
||||||
|
@ -1392,7 +1392,8 @@ func TestQueryRows(t *testing.T) {
|
|||||||
|
|
||||||
var ids []int
|
var ids []int
|
||||||
var usernames []string
|
var usernames []string
|
||||||
num, err = dORM.Raw("SELECT id, user_name FROM user ORDER BY id asc").QueryRows(&ids, &usernames)
|
query = fmt.Sprintf("SELECT %sid%s, %suser_name%s FROM %suser%s ORDER BY %sid%s ASC", Q, Q, Q, Q, Q, Q, Q, Q)
|
||||||
|
num, err = dORM.Raw(query).QueryRows(&ids, &usernames)
|
||||||
throwFailNow(t, err)
|
throwFailNow(t, err)
|
||||||
throwFailNow(t, AssertIs(num, 3))
|
throwFailNow(t, AssertIs(num, 3))
|
||||||
throwFailNow(t, AssertIs(len(ids), 3))
|
throwFailNow(t, AssertIs(len(ids), 3))
|
||||||
|
Loading…
Reference in New Issue
Block a user