gorma icon indicating copy to clipboard operation
gorma copied to clipboard

Unsupported type: 0x8 array in unnamed BuildSource

Open tpoxa opened this issue 7 years ago • 2 comments

I do use Array and Hash in my payload for resource

Payload


var CreateUpdateCampaignPayload = Type("CreateUpdateCampaignPayload", func() {

	Attribute("description", String, func() {
		Example("Campaign description")
	})

	Attribute("urlTemplate", String, func() {
		Example("http://offers.com/offer1")
		Format("uri")
	})

	Attribute("defaultBid", Number, func() {
		Example(0.00150)
	})

	Attribute("dailyBalance", Number, func() {
		Example(100)
	})

	Attribute("countryBids",  HashOf(String, String), func() {
		var m = make(map[string]string);
		m["UK"] = "0.01";
		Example(m)
	})

	Attribute("dateFrom", String, func() {
		Example("2017-01-01")
	})

	Attribute("dateTo", String, func() {
		Example("2018-01-01")
	})

	Attribute("maxClicksPerIpPer24h", Integer, func() {
		Example(5)
	})

	Attribute("adult", String, func() {
		Enum("adult", "noadult", "both")
		Example("both")
	})

	Attribute("timeRange", ArrayOf(String), func() {
		Example([]string{"Mon08-24","Tue00-05","Tue08-24"})
	})

	Attribute("bidScheme", String, func() {
		Example("smart")
	})

	Attribute("sourcesWhiteList", ArrayOf(String), func() {
		Example([]string{"a", "b"})
	})

	Attribute("sourcesBlackList", ArrayOf(String), func() {
		Example([]string{"c", "d"})
	})

	Attribute("countries", ArrayOf(String), func() {
		Example([]string{"uk", "de"})
	})

	Attribute("osWhiteList", ArrayOf(String), func() {
		Example([]string{"MacOS", "Windows"})
	})

	Attribute("browsersWhiteList", ArrayOf(String), func() {
		Example([]string{"Chrome", "Safari"})
	})

	Attribute("categoriesWhiteList", ArrayOf(String), func() {
		Example([]string{"caregory1", "caregory2"})
	})
})

Resource

var _ = Resource("campaign", func() {
	DefaultMedia(Account)
	BasePath("/campaign")


	Action("create", func() {
		Routing(
			POST("/details"),
		)
		Payload(CreateUpdateCampaignPayload, func(){
			Required("description")
			Required("urlTemplate")
			Required("defaultBid")
			Required("dailyBalance")
		})
		Description("Creates new campaign")

		Response(OK, CommonResponse)
		Response(BadRequest, ErrorMedia)

	})
})

Model


var _ = StorageGroup("Storage", func() {
	Description("This is the global storage group")
	Store("mysql", gorma.MySQL, func() {
		Model("CampaignModel", func() {

			BuildsFrom(func() {
				Payload("campaign", "create")
			})
			RendersTo(CampaignMediaType)						// a Media Type definition
			Description("Campaign model")

			Field("ID", gorma.Integer, func() {    // Required for CRUD getters to take a PK argument!
				PrimaryKey()
				Description("This is the ID PK field")
			})

			Field("CreatedAt", gorma.Timestamp)
			Field("UpdatedAt", gorma.Timestamp)			 // Shown for demonstration
			Field("DeletedAt", gorma.NullableTimestamp)  // These are added by default
		})
	})
})

An error

[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource
[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource
[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource
[design/db.go:13] Unsupported type: 0xa hash in unnamed BuildSource
[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource
[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource
[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource
[design/db.go:13] Unsupported type: 0x8 array in unnamed BuildSource

tpoxa avatar Jul 20 '17 09:07 tpoxa

Is there any possibility ignore some fields from Payload() or set a list of useful ones

What could be a temporary solution? Thank you in advance.

tpoxa avatar Jul 20 '17 09:07 tpoxa

@tpoxa You can try this https://github.com/jirfag/go-queryset to generate some code ! 👍

JermineHu avatar Nov 18 '17 09:11 JermineHu