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
When I run sqlc generate, it generates interface{} for my custom select fields.
I couldn't find how to define type for this fields. Is there any way to do it?
Relevant log output
No response
Database schema
CREATETABLEtest_table (
id int unsigned NOT NULL AUTO_INCREMENT,
val1 intNOT NULL,
val2 intNOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
SQL queries
-- name: GetData :manySELECT test_table.*,
CASE
WHEN test_table.val1=100 THEN test_table.val1 ELSE test_table.val2
END AS final_val
from test_table;
I can't see a way to get MySQL to CAST() to a regular INT, but this convinces sqlc to return an int64 at least:
-- name: GetData :manySELECT test_table.*,
CAST(
CASE
WHEN test_table.val1=100 THEN test_table.val1 ELSE test_table.val2
END
AS SIGNED) AS final_val
from test_table;
adding to this, if I use INT or BIGINT I received this error
only SIGNED and UNSIGNED worked.
And if I don't do the CAST, the fields are set as interface type, and even casting manually to int64 the data returned is wrong, it didn't worked the interface type.
Version
1.23.0
What happened?
When I run
sqlc generate
, it generates interface{} for my custom select fields.I couldn't find how to define type for this fields. Is there any way to do it?
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/ded46511e671b26f426512a2248d30b6d7707ca404b55d163d0c1705e744791c
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: