3 ms·
Marshalling support is useful. SQL result -> struct and struct -> SQL insert code is repetitive to write. Getting fancier than that may be overkill. Marshall
by Animats 10y ago
Marshalling support is useful. SQL result -> struct and struct -> SQL insert code is repetitive to write. Getting fancier than that may be overkill.
Marshalling in general needs more compile-time support. Kludges such as Google protocol buffer preprocessors are a fast but clunky way to do it. It would be useful if languages could be given a reference to an SQL CREATE TABLE and could use that information usefully. Field names, type information, and enum values should come from the CREATE TABLE info.
- deleted 10y ago[deleted]
- dhd415 10y agoThis is the sweet spot of ORMs. A team lead early in my career wrote a tool that read the database schema and generated all the marshaling code at the application layer. We got a degree of type safety and relief from a lot of boilerplate code but no promises of automatically generating SQL or abstracting away the database schema, etc. It worked so well that I wrote one from scratch in another language a decade later for another database-backed application.
- kenshaw 10y agoWe released a tool, xo, that generates safe and idiomatic Go code from a database schema that does not make any use of an ORM. I have been meaning to add support for generating code for other languages but have not yet had time to do that. That said, it is very easy and very straightforward to do so. Check it out: https://github.com/knq/xo https://github.com/knq/xo
- kawera 10y agoxo is great, we've used it a few times for existing databases, great timesaver. Thanks!
- moosingin3space 10y agoDespite not being a huge Go fan myself, I do appreciate this aspect of Go's database/sql and sqlx packages.
- deleted 10y ago[deleted]