Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error when I use ArrayOf in payload and Gorma #116

Open
MohamedFAhmed opened this issue Jun 30, 2016 · 7 comments
Open

build error when I use ArrayOf in payload and Gorma #116

MohamedFAhmed opened this issue Jun 30, 2016 · 7 comments

Comments

@MohamedFAhmed
Copy link

MohamedFAhmed commented Jun 30, 2016

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")
    })
@raphael
Copy link
Member

raphael commented Jun 30, 2016

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?

@MohamedFAhmed
Copy link
Author

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

@raphael
Copy link
Member

raphael commented Jun 30, 2016

OK this may be a current limitation of gorma, @bketelsen should chime in.

@bketelsen
Copy link
Member

can you share your design in a gist or github link? I'd like to replicate this. @MohamedFAhmed

@schmorrison
Copy link

schmorrison commented Dec 18, 2016

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.

@agui2200
Copy link

I use the Any Type in payload ,has Error too ,error:Unsupported type: 0x7 any in unnamed BuildSource
delete this,all ok

@robsliwi
Copy link

robsliwi commented Sep 3, 2018

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants