ozzo-dbx icon indicating copy to clipboard operation
ozzo-dbx copied to clipboard

support populate slice of struct pointer.

Open darasion opened this issue 7 years ago • 3 comments

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.

darasion avatar Sep 18 '17 05:09 darasion

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

kPshi avatar Sep 28 '17 10:09 kPshi

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.

kPshi avatar Oct 13 '17 13:10 kPshi

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

ganigeorgiev avatar Jan 27 '22 11:01 ganigeorgiev