mirror of
https://github.com/astaxie/beego.git
synced 2025-07-02 23:40:19 +00:00
orm 1. complete QueryRow/QueryRows api 2. QuerySeter.All support *[]Type and *[]*Type
This commit is contained in:
22
orm/db.go
22
orm/db.go
@ -479,15 +479,19 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
|
||||
ind := reflect.Indirect(val)
|
||||
|
||||
errTyp := true
|
||||
|
||||
one := true
|
||||
isPtr := true
|
||||
|
||||
if val.Kind() == reflect.Ptr {
|
||||
fn := ""
|
||||
if ind.Kind() == reflect.Slice {
|
||||
one = false
|
||||
if ind.Type().Elem().Kind() == reflect.Ptr {
|
||||
typ := ind.Type().Elem().Elem()
|
||||
typ := ind.Type().Elem()
|
||||
switch typ.Kind() {
|
||||
case reflect.Ptr:
|
||||
fn = getFullName(typ.Elem())
|
||||
case reflect.Struct:
|
||||
isPtr = false
|
||||
fn = getFullName(typ)
|
||||
}
|
||||
} else {
|
||||
@ -601,13 +605,21 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
|
||||
if one {
|
||||
ind.Set(mind)
|
||||
} else {
|
||||
slice = reflect.Append(slice, mind.Addr())
|
||||
if cnt == 0 {
|
||||
slice = reflect.New(ind.Type()).Elem()
|
||||
}
|
||||
|
||||
if isPtr {
|
||||
slice = reflect.Append(slice, mind.Addr())
|
||||
} else {
|
||||
slice = reflect.Append(slice, mind)
|
||||
}
|
||||
}
|
||||
}
|
||||
cnt++
|
||||
}
|
||||
|
||||
if one == false {
|
||||
if one == false && cnt > 0 {
|
||||
ind.Set(slice)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user