mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
修复gdb.GetAll针对返回数据列表的for..range...的返回结果slice相同指针问题
This commit is contained in:
@ -95,8 +95,12 @@ func (db *Db) GetAll(query string, args ...interface{}) (Result, error) {
|
||||
}
|
||||
row := make(Record)
|
||||
for i, col := range values {
|
||||
row[columns[i]] = Value(col)
|
||||
k := columns[i]
|
||||
v := make([]byte, len(col))
|
||||
copy(v, col)
|
||||
row[k] = v
|
||||
}
|
||||
//fmt.Printf("%p\n", row["typeid"])
|
||||
records = append(records, row)
|
||||
}
|
||||
return records, nil
|
||||
|
||||
@ -478,7 +478,7 @@ func mapToStruct() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
r, _ := db.Table("user").Select()
|
||||
r, _ := db.Table("user").Fields("*").Where("typeid = ?", 1).Limit(0, 10).Select()
|
||||
j, _ := gparser.VarToJson(r.ToList())
|
||||
fmt.Println(string(j))
|
||||
fmt.Println(r)
|
||||
|
||||
Reference in New Issue
Block a user