Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Go 1.18: Generics and sqlc #1342

Unanswered
kyleconroy asked this question in Issue Triage
Dec 14, 2021 · 2 comments · 3 replies
Discussion options

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.

You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

The one really gaping feature is around being able to do batch insert, but I don't know how/if generics would help with that.
...
On Tue, Dec 14, 2021 at 2:18 PM Kyle Conroy ***@***.***> wrote: 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. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1342>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AML53FMFZ6VKAMGM7J7SKS3UQ67FBANCNFSM5KCDAOKA> . Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
3 replies
Comment options

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.

Comment options

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.

Comment options

This is a good feature to have really soon, if not already implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /