improve some functions
This commit is contained in:
parent
23c6999de8
commit
1d5bc623f3
|
@ -886,8 +886,10 @@ func (session *Session) getByPK(pk core.PK, fieldValue *reflect.Value) error {
|
|||
if has {
|
||||
if fieldValue.Kind() == reflect.Ptr && fieldValue.IsNil() {
|
||||
fieldValue.Set(structInter)
|
||||
fmt.Println("getByPK value ptr:", fieldValue.Interface())
|
||||
} else if fieldValue.Kind() == reflect.Struct {
|
||||
fieldValue.Set(structInter.Elem())
|
||||
fmt.Println("getByPK value:", fieldValue.Interface())
|
||||
} else {
|
||||
return errors.New("set value failed")
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package xorm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -164,6 +165,7 @@ func TestBelongsTo_Find(t *testing.T) {
|
|||
err = testEngine.Cascade().Find(&noses2)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(noses2))
|
||||
fmt.Println("noses:", noses2)
|
||||
assert.Equal(t, face1.Id, noses2[0].Face.Id)
|
||||
assert.Equal(t, face2.Id, noses2[1].Face.Id)
|
||||
assert.Equal(t, "face1", noses2[0].Face.Name)
|
||||
|
|
|
@ -203,7 +203,9 @@ func (session *Session) noCacheFind(table *core.Table, containerValue reflect.Va
|
|||
if isPointer {
|
||||
containerValue.Set(reflect.Append(containerValue, newValue.Elem().Addr()))
|
||||
} else {
|
||||
fmt.Println("---", newValue.Elem())
|
||||
containerValue.Set(reflect.Append(containerValue, newValue.Elem()))
|
||||
fmt.Println("===", containerValue.Interface())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue