3 ms·
I wrote a similar tool for Go and Postgres but it also generates the serialization code. [1] - I prefer generating code from queries instead of generating act
by sa46 5y ago
I wrote a similar tool for Go and Postgres but it also generates the serialization code. [1]
- I prefer generating code from queries instead of generating active record style models based on tables.
- I think it’s worth it to spin up Postgres to get type info instead of trying to parse queries. Reimplementing Postgres’ type inference is a Herculean task even with an AST. Sqlc, which directly inspired pggen does this.
- It’s hard to support customization of generated code in a structured way. The way I’m leaning towards is if you need customization, you need to use the SDK which provides plugin hooks. Using flags for customization is the road to madness.
- What I would like to do is serialize directly to protobuf to avoid the serialization dance of Go structs to Proto structs.
[1]: https://github.com/jschaf/pggen https://github.com/jschaf/pggen