Open Tommy-42 opened 6 years ago
We provide customtype
for bytes and messages, but not for int32s. Here people typically rely on casttype
, but the type should be castable, which is not the case for string and int32. I don't think we provide such an option.
Does postgres maybe allow you to define a custom method that can cast your enum to a string and back? Just like you can define custom marshal and unmarshal methods for protobufs?
You should be able to just write your own Scanner/Valuer. I don't think this should be the job of this library. https://husobee.github.io/golang/database/2015/06/12/scanner-valuer.html https://www.reddit.com/r/golang/comments/710a1s/sql_valuerscanner_interface_issue/ https://gist.github.com/jmoiron/6979540
Hello, I am in a bit in a dead-end here. I have looked at the other issues about enum and string, but I think they didn;t match my case.
My case is : my db is
POSTGRES
and I usego-pg
as orm.my proto contain enum that are generated like this :
the problem is :
postgres
store enum as astring/varchar
when I perform a select, the orm get the data then try to convert it to
int32
( since in with proto enum are init as int32 ).Is there a way to generate enum as string
type Contact_Language string
instead oftype Contact_Language int32
.Does gogo/protobuf should have this option, or maybe you would have a solution for that ?
what do you think ?