mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
fix issue #1202
This commit is contained in:
parent
54395b39a6
commit
bb6883213f
@ -189,5 +189,5 @@ func (r Result) RecordKeyUint(key string) map[uint]Record {
|
|||||||
// Structs converts `r` to struct slice.
|
// Structs converts `r` to struct slice.
|
||||||
// Note that the parameter `pointer` should be type of *[]struct/*[]*struct.
|
// Note that the parameter `pointer` should be type of *[]struct/*[]*struct.
|
||||||
func (r Result) Structs(pointer interface{}) (err error) {
|
func (r Result) Structs(pointer interface{}) (err error) {
|
||||||
return gconv.StructsTag(r, pointer, OrmTagForStruct)
|
return gconv.StructsTag(r.List(), pointer, OrmTagForStruct)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ package gdb_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"github.com/gogf/gf/database/gdb"
|
|
||||||
"github.com/gogf/gf/frame/g"
|
"github.com/gogf/gf/frame/g"
|
||||||
"github.com/gogf/gf/os/gtime"
|
"github.com/gogf/gf/os/gtime"
|
||||||
"github.com/gogf/gf/test/gtest"
|
"github.com/gogf/gf/test/gtest"
|
||||||
@ -383,7 +382,7 @@ func Test_Model_Scan_CustomType_String(t *testing.T) {
|
|||||||
err := db.Model(table).Fields("Passport").Order("id asc").Scan(&sts)
|
err := db.Model(table).Fields("Passport").Order("id asc").Scan(&sts)
|
||||||
t.AssertNil(err)
|
t.AssertNil(err)
|
||||||
t.Assert(len(sts), TableSize)
|
t.Assert(len(sts), TableSize)
|
||||||
t.Assert(sts[0], "user_1")
|
t.Assert(sts[0].Passport, "user_1")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,11 +397,11 @@ type User struct {
|
|||||||
func (user *User) UnmarshalValue(value interface{}) error {
|
func (user *User) UnmarshalValue(value interface{}) error {
|
||||||
switch result := value.(type) {
|
switch result := value.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
user.Id = result["id"].(gdb.Value).Int()
|
user.Id = result["id"].(int)
|
||||||
user.Passport = result["passport"].(gdb.Value).String()
|
user.Passport = result["passport"].(string)
|
||||||
user.Password = ""
|
user.Password = ""
|
||||||
user.Nickname = result["nickname"].(gdb.Value).String()
|
user.Nickname = result["nickname"].(string)
|
||||||
user.CreateTime = result["create_time"].(gdb.Value).GTime()
|
user.CreateTime = gtime.New(result["create_time"])
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return gconv.Struct(value, user)
|
return gconv.Struct(value, user)
|
||||||
|
Loading…
Reference in New Issue
Block a user