Skip to content

E0501: A Schema field isn't the model's ​

A model's Schema method names each field by its address, &p.Title, and the orm maps the address back to a field of the model it calls Schema on. s.Field is given something else — a value, a variable's address, an element of an array — or Schema has a value receiver, whose fields' addresses are a copy's. Reported by every query of the model, orm.Check and vukavet.

Wrong ​

go
func (p Post) Schema(s *orm.Schema) {
	s.Field(p.Title, orm.Char{Max: 200})
}
go
func (p *Post) Schema(s *orm.Schema) {
	s.Field(&p.Title, orm.Char{Max: 200})
}

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.