You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Thank you for the library. I have a question though: in go's implementation of sqlc gen when working with queries such as SELECT * FROM users you get []User in code, same type for all results of selecting full data from users table. In this library each query gets its own *Row result, even in such cases. Is this intentional, can it be configured otherwise?
This is intentional, in the sense that it's how the generator is built today: every query that returns columns gets its own <QueryName>Row type, even when the columns are identical to a table's model. Unlike sqlc-gen-go, we don't detect that a query's result matches a table's columns and reuse the model. There's currently no option to change this.
The only related feature is sqlc.embed(table), which makes the embedded part of the row use the existing model type (as a field inside the Row class).
I agree that reusing the model for SELECT * queries would be nicer, since you could pass results around without mapping. It would make a good opt-in feature, so existing generated code doesn't get renamed. A possible design is an option (say reuseModelsForRows) that returns []User when a query's result columns match a table's columns exactly, the way sqlc-gen-go does.
If that's something you'd use, I'm happy to take a look, or a PR is welcome. how would yo see this implemented?
Activity
doron050 commentedon Oct 24, 2026
Hi, and thanks for the kind words!
This is intentional, in the sense that it's how the generator is built today: every query that returns columns gets its own
<QueryName>Rowtype, even when the columns are identical to a table's model. Unlike sqlc-gen-go, we don't detect that a query's result matches a table's columns and reuse the model. There's currently no option to change this.The only related feature is
sqlc.embed(table), which makes the embedded part of the row use the existing model type (as a field inside theRowclass).I agree that reusing the model for
SELECT *queries would be nicer, since you could pass results around without mapping. It would make a good opt-in feature, so existing generated code doesn't get renamed. A possible design is an option (sayreuseModelsForRows) that returns[]Userwhen a query's result columns match a table's columns exactly, the way sqlc-gen-go does.If that's something you'd use, I'm happy to take a look, or a PR is welcome. how would yo see this implemented?