Open
Description
Version
1.28.0
What happened?
-- name: UpcreateUserAccountBalance :execresult
INSERT INTO user_balance (
user_id,
amount,
create_time,
update_time
) VALUES (
?,
?,
now(),
now()
)
as new_item
ON DUPLICATE KEY UPDATE
amount = new_item.amount,
update_time = now();
syntax error near "as new_item "
Relevant log output
syntax error near "as new_item "
Database schema
CREATE TABLE `user_balance` (
`id` bigint NOT NULL AUTO_INCREMENT ,
`user_id` varchar(64) NOT NULL DEFAULT '' ,
`amount` decimal(65,30) NOT NULL DEFAULT '0.000000000000000000000000000000',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC;
SQL queries
-- name: UpcreateUserAccountBalance :execresult
INSERT INTO user_balance (
user_id,
amount,
create_time,
update_time
) VALUES (
?,
?,
now(),
now()
)
as new_item
ON DUPLICATE KEY UPDATE
amount = new_item.amount,
update_time = now();
Configuration
version: "2"
plugins:
sql:
- engine: "mysql"
queries: "./sql/queries/"
schema: "./sql/schema/"
gen:
go:
package: "repository"
out: "internal/repository"
emit_db_tags: true
overrides:
- db_type: "decimal"
go_type: "float64"
Playground URL
https://play.sqlc.dev/p/e4180de8a61bce51224656a0464de8b9c7be9ef46c2315b5bc26990a76ef1e13
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go