sqlc
sqlc copied to clipboard
CAST() produces correct go type for postgres but not mysql
Version
1.25.0
What happened?
CAST and CONVERT don't produce correct go types for mysql
-- name: GetAuthors :many
SELECT id, CAST(name AS CHAR(50)) AS castedName
FROM authors;
produces this for postgres
type GetAuthorsRow struct {
ID sql.NullInt32
Castedname string
}
but this for mysql
type GetAuthorsRow struct {
ID sql.NullInt32
Castedname interface{}
}
As a workaround I can cheat by wrapping cast() with concat().
SELECT id, concat(CAST(name AS CHAR(50))) AS castedName
FROM authors;
Playground URL
https://play.sqlc.dev/p/f564780effa348c312a8a3c85bb9b2cfa093d56538f945ee439aa476847df247
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go