Handling Circular Schema
Closed this issue · 2 comments
freb commented
I'm wondering if this library supports circular relationships. Here are two examples I tried, including one from the dgo
docs:
type A struct {
UID string `json:"uid,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
Name string `json:"a.name,omitempty"`
B []*B `json:"a.b,omitempty dgraph:"count reverse"`
}
type B struct {
UID string `json:"uid,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
Name string `json:"b.name,omitempty"`
A []*A `json:"~a.b,omitempty"`
}
func main() {
c := newDgraphClient()
schema, err := dgman.CreateSchema(c, &A{}, &B{})
if err != nil {
panic(err)
}
fmt.Println(schema)
}
And the other is
type Person struct {
Uid string `json:"uid,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
Name string `json:"name,omitempty"`
Friends []Person `json:"friends,omitempty"`
}
Both of these end in a goroutine stack exceeds 1000000000-byte limit
error.
go/pkg/mod/github.com/dolan-in/dgman@v1.2.0/schema.go:206 +0x280 fp=0xc020480628 sp=0xc0204805d0 pc=0x893050
github.com/dolan-in/dgman.parseDgraphTag(0xc020480978, 0x17, 0x8bc5f9, 0x5)
go/pkg/mod/github.com/dolan-in/dgman@v1.2.0/schema.go:235 +0x64 fp=0xc0204806b0 sp=0xc020480628 pc=0x893204
github.com/dolan-in/dgman.(*TypeSchema).Marshal(0xc0001fe690, 0xc008d8ea01, 0xc008d8ea40, 0x1, 0x1)
go/pkg/mod/github.com/dolan-in/dgman@v1.2.0/schema.go:150 +0x2a3 fp=0xc0204809f0 sp=0xc0204806b0 pc=0x892403
github.com/dolan-in/dgman.(*TypeSchema).Marshal(0xc0001fe690, 0xc008d8e901, 0xc008d8e970, 0x1, 0x1)
go/pkg/mod/github.com/dolan-in/dgman@v1.2.0/schema.go:166 +0x4ce fp=0xc020480d30 sp=0xc0204809f0 pc=0x89262e
github.com/dolan-in/dgman.(*TypeSchema).Marshal(0xc0001fe690, 0xc008d8e801, 0xc008d8e8b0, 0x1, 0x1)
go/pkg/mod/github.com/dolan-in/dgman@v1.2.0/schema.go:166 +0x4ce fp=0xc020481070 sp=0xc020480d30 pc=0x89262e
github.com/dolan-in/dgman.(*TypeSchema).Marshal(0xc0001fe690, 0xc008d8e701, 0xc008d8e7f0, 0x1, 0x1)
I didn't see any circular examples in the README, so I thought I'd ask. Thanks
wildan2711 commented
Interesting.. Yes, I have not handled circular relationships. I'll see what I can do.