gorma
gorma copied to clipboard
build error when I use ArrayOf in payload and Gorma
We're expecting in one of our payloads and object that has basic attributes and array of objects in it. . However, I get these errors when we use gorma.
**models/clc.go:178: cannot use payload.Containers (type string) as type []Container in assignment models/clc.go:203: cannot use payload.Containers (type string) as type []Container in assignment
This is how the payload is defined
`var ClcPayload = Type("ClcPayload", func() {
Attribute("name", String, func() {
MinLength(1)
MaxLength(1024)
})
Attribute("labels", func(){
ArrayOf(LabelPayload)
})
Attribute("description", String, func(){
MinLength(0)
MaxLength(1024)
})
Attribute("replicas", Integer, func(){
Minimum(1)
Maximum(10)
})
Attribute("containers", func(){
ArrayOf(ContainerPayload)
})
})`
var ContainerPayload = Type("ContainerPayload", func() {
Attribute("name", String, func() {
MinLength(1)
MaxLength(1024)
})
Attribute("labels", func(){
ArrayOf(LabelPayload)
})
Attribute("description", String, func(){
MinLength(0)
MaxLength(1024)
})
Attribute("image_url", String)
Attribute("ports", func(){
ArrayOf(PortPayload)
})
Attribute("envs", func(){
ArrayOf(EnvPayload)
})
Attribute("commands", func(){
ArrayOf(String)
})
Attribute("icus", Integer)
Attribute("memory", Integer)
Attribute("replicas", Integer, func(){
Minimum(1)
Maximum(10)
})
//Attribute("volumes", ArrayOf(VolumePayload))
})`
This is the definition of our data model
Model("Clc", func() {
BuildsFrom(func() {
Payload("clc", "create")
Payload("clc", "update")
})
RendersTo(Clc)
HasMany("Containers", "Container")
Description("Colocated Container Model Description")
Field("id", gorma.UUID, func() {
PrimaryKey()
Description("This is the Clc Model PK field")
})
BelongsTo("Service")
})
It looks like the definition is off for containers, instead of:
Attribute("containers", func(){
ArrayOf(ContainerPayload)
})
It should be:
Attribute("containers", ArrayOf(ContainerPayload))
Does the error still occur if you make that change?
Thanks for your response Raphael.
Yes we did change it to that and got this error
([design/models.go:61] Unsupported type: 0x8 array in unnamed BuildSource
OK this may be a current limitation of gorma, @bketelsen should chime in.
can you share your design in a gist or github link? I'd like to replicate this. @MohamedFAhmed
I received the following error, could be related:
[../design/storage.go:35] Unsupported type: 0x6 string in unnamed BuildSource
[../design/storage.go:35] Unsupported type: 0x8 array in unnamed BuildSource
[../design/storage.go:55] Unsupported type: 0x6 string in unnamed BuildSource
[../design/storage.go:76] Unsupported type: 0x8 array in unnamed BuildSource
[../design/storage.go:13] Unsupported type: 0x6 string in unnamed BuildSource
I seem to have resolved it by making sure the "name" of my Types were not the same as the "name" of my Resources. I can put my design files somewhere if you would like.
I use the Any Type in payload ,has Error too ,error:Unsupported type: 0x7 any in unnamed BuildSource delete this,all ok
I'm getting Unsupported type: 0x8 array in unnamed BuildSource
like @MohamedFAhmed and can share the gist if you like, @bketelsen.
You could reproduce the error by defining something simple like Attribute("identifiersArray", ArrayOf(String)
.