-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
Converting database objects into their protobuf representation is a common task, and it would be nice if pggen
could automate that. Obviously, this shouldn't be on by default, there should be a per-table flag.
Ideally, protoc would generate setters so that we could program to an interface that allows db tables to be assigned to protobufs that are a superset of the table (because we need to support computed fields). It doesn't seem like this is the case, so I think we will have to fall back on reflection or protobuf extension shenanigans. I'm not sure exactly what that could look like. There are a few options:
- Have pggen generate the reflection based code itself. The assignment methods accept an
interface{}
as their target. - Have pggen generate structs made out of protobuf types and target them. Users can then call some
Assign
method that uses reflection to match things up based on field name. - Have pggen generate the code it wants as well as an extensions file that needs to be injected into the protobufs module. This would contain the setters that it needs.