File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 5
5
"fmt"
6
6
"reflect"
7
7
"strings"
8
+ "sync"
8
9
9
10
"github.com/jinzhu/inflection"
10
11
"golang.org/x/text/cases"
@@ -32,6 +33,8 @@ type Relationships struct {
32
33
Relations map [string ]* Relationship
33
34
34
35
EmbeddedRelations map [string ]* Relationships
36
+
37
+ Mux sync.RWMutex
35
38
}
36
39
37
40
type Relationship struct {
@@ -98,9 +101,10 @@ func (schema *Schema) parseRelation(field *Field) *Relationship {
98
101
}
99
102
100
103
if relation .Type == has {
101
- // don't add relations to embedded schema, which might be shared
102
104
if relation .FieldSchema != relation .Schema && relation .Polymorphic == nil && field .OwnerSchema == nil {
105
+ relation .FieldSchema .Relationships .Mux .Lock ()
103
106
relation .FieldSchema .Relationships .Relations ["_" + relation .Schema .Name + "_" + relation .Name ] = relation
107
+ relation .FieldSchema .Relationships .Mux .Unlock ()
104
108
}
105
109
106
110
switch field .IndirectFieldType .Kind () {
You can’t perform that action at this time.
0 commit comments