Special type without defining a special type in SQL #3509
Unanswered
emil-petras
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be great if we could generate custom Go types (like SpecialType), based on existing SQL types (like string), without having to define a new SQL type. Essentially, I want to create a Go type that wraps around an existing SQL type directly.
-- name: GetSpecialTypes :many SELECT id, name ::specialtype FROM table
And then have sqlc generate the following code:
type SpecialTable struct { ID int64 Name SpecialType }
This is currently possible, but you have to define a custom sql type.
Implementation:
One way to do this might be to add a tag or directive in the sqlc configuration or SQL queries. This would tell sqlc to use the desired Go type without needing a corresponding SQL type.
Beta Was this translation helpful? Give feedback.
All reactions