sqlc
sqlc copied to clipboard
Repeated use of the same sqlc.arg() in MySQL generates a struct argument
Version
1.15.0
What happened?
When I use sqlc.arg(blah) twice in the same query and no other parameters, I'd expect the generated query method to have a blah int argument, rather than a arg MyQueryParams argument.
This works correctly for PostgreSQL. (The difference is that Postgres can just repeat $1 in the query and be done. MySQL needs to repeat the ? and pass the value twice.)
Relevant log output
No response
Database schema
CREATE TABLE authors (
a INT,
b INT
);
SQL queries
-- name: CreateAuthor :exec
INSERT INTO authors (a, b) VALUES (sqlc.arg(num), sqlc.arg(num));
Configuration
No response
Playground URL
https://play.sqlc.dev/p/3027a540baa98c5ae82fdbb0eb7c2779347f9c9485e9b88880036bcc9dad1b8e
What operating system are you using?
Linux
What database engines are you using?
MySQL
What type of code are you generating?
Go
Huh, this is most certainly a bug.