-
Notifications
You must be signed in to change notification settings - Fork 885
Named parameters don't work in sqlc with MySQL #1791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I see this is at partly a dupe of #695 - where slices aren't supported in MySQL. I'm not sure about the |
MySQL is fully supported in sqlc. Many of the queries in your bug report aren't valid, hence the compilation failures. First, the shorthand CAST operator ( Feel free to open up a new issue if you run into other issues. |
helo @kyleconroy UPDATE users
SET
first_name = IF(CAST(sqlc.arg(set_first_name) AS boolean) = true, CAST(sqlc.arg(first_name) AS varchar), first_name),
last_name = IF( CAST(sqlc.arg(set_last_name) AS boolean) = true, CAST(sqlc.arg(last_name) AS varchar), last_name),
avatar = IF( CAST(sqlc.arg(set_avatar) AS boolean) = true, CAST(sqlc.arg(avatar) AS TEXT), avatar),
updated_at = now()
WHERE id = ? and deleted_at is null; why i igot error sqlc/query/users.sql:24:61: syntax error near "boolean) = true, CAST(sqlc.arg(first_name) AS varchar), first_name)," i use mysql v8 |
I feel that SQLC is only suitable for PostgreSQL. |
i'm using it with sqlite. sqlc for sqlite is still buggy but already good enough. hope it'll be as good as for postgres soon. |
not working |
|
Uh oh!
There was an error while loading. Please reload this page.
What happened?
Version:
Running
sqlc generate
on this query:Fails to parse, with:
Trying to use
ANY
like the docs say doesn't work, it was unclear if this was postgres or mysql syntax at first, but for some reason the docs seem to hard code postgres syntax, and the playground only supports postres:Fails to parse, with
(it's weird it fails to parse on a different place, not the ANY which is invalid mysql syntax
Ok, let's try with
arg()
insteadSo
sqlc generate
passes here, except it generates a null string, not a sliceok the docs tell us to append
::int[]
as a type hint, soCrashes sqlc once again:
Ok, not sure what's going on, named arguments don't seem supported. Let's try them in a different place:
Now we have three problems:
sqlc
is successful... WHERE CASE WHEN ?
and there is notest
argument added to the generated golang codeOk maybe it's missing a type hint?
Except that crashes the parser again:
Should we consider the mysql as supported in sqlc, or something in beta/experimental mode? It does not appear usable, and the docs don't mention how to use MySQL syntax, unless I'm missing something obvious
The text was updated successfully, but these errors were encountered: