mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 03:05:05 +08:00
fix issue #1700
This commit is contained in:
parent
f1fee72d6d
commit
f9a3fa3c23
@ -4256,6 +4256,7 @@ func Test_Model_Issue1700(t *testing.T) {
|
||||
UserId: 3,
|
||||
}).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
one, err := db.Model(table).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one, g.Map{
|
||||
@ -4263,11 +4264,14 @@ func Test_Model_Issue1700(t *testing.T) {
|
||||
"user_id": 2,
|
||||
"UserId": 3,
|
||||
})
|
||||
var user *User
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Userid, 2)
|
||||
t.Assert(user.UserId, 3)
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
var user *User
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Userid, 2)
|
||||
t.Assert(user.UserId, 3)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ func IsMap(value interface{}) bool {
|
||||
// IsStruct checks whether `value` is type of struct.
|
||||
func IsStruct(value interface{}) bool {
|
||||
var (
|
||||
reflectValue = reflect.ValueOf(value)
|
||||
reflectKind = reflectValue.Kind()
|
||||
reflectType = reflect.TypeOf(value)
|
||||
reflectKind = reflectType.Kind()
|
||||
)
|
||||
for reflectKind == reflect.Ptr {
|
||||
reflectValue = reflectValue.Elem()
|
||||
reflectKind = reflectValue.Kind()
|
||||
reflectType = reflectType.Elem()
|
||||
reflectKind = reflectType.Kind()
|
||||
}
|
||||
switch reflectKind {
|
||||
case reflect.Struct:
|
||||
|
Loading…
x
Reference in New Issue
Block a user