-
Notifications
You must be signed in to change notification settings - Fork 923
Go 1.18: Generics and sqlc #1342
-
In February, Go 1.18 will be released with a long-awaited feature: generics. The 1.18beta landed today, which means it's easy to play around with them.
How would you like the Go output of sqlc to suppprt generics? I don't currently have any specific plans for drastic changes.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
All reactions
-
Go 1.18 has been released. The release notes cover the big additions. I think the first thing we'll take advantage of is fuzzing support to verify that our config parser doesn't panic on invalid input.
Second, I'd like to work on a Nullable
generic type that can work across all database drivers. This would be separate from sqlc, but we could incorporate it once it's well tested.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
A generic nullable sounds really useful to me if it implements JSON marshal/unmarshal. I like that sqlc supports emitting json tags, but ran into issues pretty quickly on tables that had null fields, since the sql.Null*
types don't implement marshal/unmarshal.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 3
-
Seeing this hack having an imports
key would be great.
As an example, you might have a generic in one package and the type in another.
go_type: imports: - package: "utils" alias: "utils1" - package: "data" alias: "data1" type: "utils1.JSONB[data2.Type]"
sqlc generates the correct struct field.
It's just missing the extra imports.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
This is a good feature to have really soon, if not already implemented
Beta Was this translation helpful? Give feedback.