You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using MYSQL functions ( CONVERT and CAST) result in removing column from struct #1622
When creating an insert query for a json column, sqlc does not generate the column name in the golang struct if I try to add CAST(CONVERT( ? USING utf8) AS JSON)
From playing around with MySql and Postgres in the playground, I've noticed that it works fine in Postgres but not when using MySql
FWIW, I'm pretty sure the root cause here is very similar to the one for #1648, namely that convertFuncCastExpr is unimplemented here for mysql.
It seemed a bit tricky to implement because of the TypeName value that needs to be populated in the ast.TypeCast node. The postgres engine implements this as:
type CreateProductVersionParams struct {
ProductID int32
ProductKey string
Version int32
Type ProductVersionsType
Status ProductVersionsStatus
CONVERT interface{}
CreatedBy int32
}
Obviously an all-uppercase field name with an interface{} type isn't ideal here.
Activity
ryanpbrewster commentedon May 28, 2022
FWIW, I'm pretty sure the root cause here is very similar to the one for #1648, namely that
convertFuncCastExpris unimplemented here for mysql.It seemed a bit tricky to implement because of the
TypeNamevalue that needs to be populated in theast.TypeCastnode. The postgres engine implements this as:but that info is not as easily accessible in the mysql engine.
You can verify this by setting the
SQLCDEBUG=1environment variable when you runsqlc. If I am correct you should see error logs likebut for a
FuncCastExprfeat(mysql): Implement cast function parser (#2473)
kyleconroy commentedon Sep 26, 2023
"Fixed" in sqlc 1.21
Obviously an all-uppercase field name with an interface{} type isn't ideal here.
feat(mysql): Implement cast function parser (sqlc-dev#2473)