Open
Description
What do you want to change?
I frequently find myself converting the results from a query to a map, keyed by one of the fields. The code looks like this:
m := map[string]gendb.User{}
users, err := gendb.QueryUsers(ctx)
for _, u := range users {
m[u.Username] = u
}
I've been holding off on this feature request hoping that generics would cleanly solve this, but solutions with generics aren't as pretty as I'd hoped. (Using a Map plus a lambda to return a field.)
Given that sqlc has all the information needed for this, it would be a neat convenience if sqlc could generate this boilerplate for me :)
I'm willing to send a PR if approved.
What database engines need to be changed?
No response
What programming language backends need to be changed?
Go