jschaf / pggen

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.
MIT License
281 stars 26 forks source link

SELECT * FROM x and UPDATE|DELETE|INSERT x RETURNING * should use the same type #58

Closed mvrhov closed 2 years ago

mvrhov commented 2 years ago

I'm evaluating a pggen to use it instead of sqlc, but there a re thing that sqlc does better, one of them is reuse of return types. The pggen generates a ton of types and it doesn't check if the types could be reused by different queries. This is especially annoying as one must do another ton of copy From/To functions for basic CRUD methods because

jschaf commented 2 years ago

Yes, this is the feature I want most as well and the one I'll implement next. I want it for the same reason: to avoid duplicating From/To functions.

There's a hacky workaround if you use the Batch and Scan methods. You can use the Scan method for any enqueued Batch as long as the types match up.

jschaf commented 2 years ago

Duplicate of #44. I'll consolidate discussion over in that issue.