File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 55 "fmt"
66 "reflect"
77 "strings"
8+ "sync"
89
910 "github.com/jinzhu/inflection"
1011 "golang.org/x/text/cases"
@@ -32,6 +33,8 @@ type Relationships struct {
3233 Relations map [string ]* Relationship
3334
3435 EmbeddedRelations map [string ]* Relationships
36+
37+ Mux sync.RWMutex
3538}
3639
3740type Relationship struct {
@@ -98,9 +101,10 @@ func (schema *Schema) parseRelation(field *Field) *Relationship {
98101 }
99102
100103 if relation .Type == has {
101- // don't add relations to embedded schema, which might be shared
102104 if relation .FieldSchema != relation .Schema && relation .Polymorphic == nil && field .OwnerSchema == nil {
105+ relation .FieldSchema .Relationships .Mux .Lock ()
103106 relation .FieldSchema .Relationships .Relations ["_" + relation .Schema .Name + "_" + relation .Name ] = relation
107+ relation .FieldSchema .Relationships .Mux .Unlock ()
104108 }
105109
106110 switch field .IndirectFieldType .Kind () {
You can’t perform that action at this time.
0 commit comments