Skip to content
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

sqlite: appears to be confused by sqlc.arg or parentheses #1954

Closed
mvdan opened this issue Nov 15, 2022 · 3 comments
Closed

sqlite: appears to be confused by sqlc.arg or parentheses #1954

mvdan opened this issue Nov 15, 2022 · 3 comments

Comments

@mvdan
Copy link

mvdan commented Nov 15, 2022

Version

Other

What happened?

I have been using sqlc for over a year with sqlite, by using the mysql engine and holding it in the right way so that the generated code would be compatible with sqlite.

Now that sqlite is supported, I tried swapping the engines. I get syntax errors, which I reduced to the bits of code below.

This is with sqlc 1.16.0. I think the template is out of date: I could not pick this version, nor could I pick sqlite as the engine.[

Relevant log output

sqlc generate failed.

line 3:13 mismatched input '(' expecting {')', ','}
# package db
query.sql:1:1: mismatched input '(' expecting {')', ','}

Database schema

Not needed, really. The error happens when parsing the query.

SQL queries

-- name: GetPeople :many
SELECT ID FROM people
WHERE (LENGTH(sqlc.arg(name)) = 0);

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "sqlite",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/a375863b4700d7104acad69d85e9c9b55f6611eb3a8214af946e490339b38e59

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

@mvdan mvdan added bug Something isn't working triage New issues that hasn't been reviewed labels Nov 15, 2022
@mvdan
Copy link
Author

mvdan commented Nov 15, 2022

Possibly related to #1881, which shows errors when sqlc.narg is used with sqlite. Though the errors look different.

@andrewmbenton
Copy link
Collaborator

This may have been resolved with the merge of #2274. I know it's been awhile but if it's possible to test your engine switch with the latest sqlc dev build and report results that would be ideal. I will try to test myself once a new version of the playground ships.

@mvdan
Copy link
Author

mvdan commented Jun 13, 2023

Indeed it works! I've fully switched from using the mysql engine as a workaround to the sqlite engine :)

@mvdan mvdan closed this as completed Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants