forked from mirror/gorm
Merge pull request #305 from jnfeinstein/master
Fields are cached when withRelation, so they should only be accessed when withRelation.
This commit is contained in:
commit
1cb6e5664e
5
scope.go
5
scope.go
|
@ -411,10 +411,11 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField, withRelatio
|
||||||
|
|
||||||
// Fields get value's fields
|
// Fields get value's fields
|
||||||
func (scope *Scope) Fields(noRelations ...bool) map[string]*Field {
|
func (scope *Scope) Fields(noRelations ...bool) map[string]*Field {
|
||||||
if scope.fields != nil {
|
var withRelation = len(noRelations) == 0
|
||||||
|
|
||||||
|
if withRelation && scope.fields != nil {
|
||||||
return scope.fields
|
return scope.fields
|
||||||
}
|
}
|
||||||
var withRelation = len(noRelations) == 0
|
|
||||||
|
|
||||||
var fields = map[string]*Field{}
|
var fields = map[string]*Field{}
|
||||||
if scope.IndirectValue().IsValid() && scope.IndirectValue().Kind() == reflect.Struct {
|
if scope.IndirectValue().IsValid() && scope.IndirectValue().Kind() == reflect.Struct {
|
||||||
|
|
Loading…
Reference in New Issue