ozzo-dbx
ozzo-dbx copied to clipboard
support populate slice of struct pointer.
My code is like this:
var rows []*Row
db.Select().All(&rows)
and i got an error:
Invalid variable type: must be a slice of struct or NullStringMap
But a lot of scenarios use slice of pointers to structs, such as the codes generated by protocol buffer:
type FooRequest struct {
// ...
Rules []*RuleFile `protobuf:"bytes,2,rep,name=rules" json:"rules,omitempty"` // <-- this field
// ...
}
We need to support populate slice of struct pointer so we can pass proto message field directly without convertion.
I'm currently not on the console but I'm quite sure pull request #43 (fix for issue #42) should solve this. Maybe you want to give it a try and push it a bit. ;-)
Have you tried with
import "github.com/kPshi/ozzo-dbx"
in the meantime? That's a (currently still unmerged) fork which should fix that issue. Please give PR #43 a thumbs up if so. Would like to return to the main branch soon.
Because @kPshi's PR adds other things (and frankly I had trouble understanding what actually was happening), I've created a smaller PR that only adds the support for scanning slice of pointers - https://github.com/go-ozzo/ozzo-dbx/pull/99