sqlc
sqlc copied to clipboard
fix(sqlite): Removed ToLower in typecast
Fixes #3688 by not calling NewIdentifier(name) in convertCastExpr because this function was ending up calling strings.ToLower on the type name resulting in type overrides not matching because the cast type name was always lowerCase and the override was always uppercase in go_type.go@goInnerType.
Alternatively this issue could by changing this line in goInnerType:
if oride.DbType != "" && oride.DbType == columnType && oride.Nullable != notNull && oride.Unsigned == col.Unsigned {
to
if oride.DbType != "" && strings.EqualFold(oride.DbType, columnType) && oride.Nullable != notNull && oride.Unsigned == col.Unsigned {
But I don't know if this would be a good idea...
Since we're already here, I've added tests for this specific case of type casts + overrides in sqlite, and refacted a variable in convertCastExpr because name could be confused with the column name instead of type name.