gocql icon indicating copy to clipboard operation
gocql copied to clipboard

Allow registration of marshalers

Open JonasDoe opened this issue 4 years ago • 0 comments

I tried to match my case into the questionaire. I hope it suffices!

What version of Gocql are you using?

commit ae2f7fc85f32248f9341a280ccdad16b44581f36

What did you do?

I have a struct like User { Id: uuid.UUID, Name: string} and I wanted to write it into the database without converting it to a new struct like User { Id: gocql.UUID, Name: string} (or implementing the Marshaler interface to other types, the UUID is just an easy example) by copying every value. This would require me to know any incoming struct which hinders abstraction.

What did you expect to see?

I hoped for a method like qb.Update().WithMarshaler(...). where I could pass the marshalling logic (for example by a marshaling and an unmarshaling function) by type.

What did you see instead?

Well, I've got to define a new type implementing Marshaler so it will be used in marshal.go. Which forces me not only to reconstruct all incoming structs and replace critical fields with marshallers, but also to know every incoming strcuts and prepare a conversion method for each of them.

JonasDoe avatar Nov 15 '19 09:11 JonasDoe