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

DELETE statements with a LIMIT do not work #2291

Closed
leobrines opened this issue May 28, 2023 · 2 comments · Fixed by #2384
Closed

DELETE statements with a LIMIT do not work #2291

leobrines opened this issue May 28, 2023 · 2 comments · Fixed by #2384
Milestone

Comments

@leobrines
Copy link

Version

Other

What happened?

I tried to use LIMIT in a DELETE query but tool didn't not detect the query.

I searched about sqlite available clauses for DELETE. By default, SQLite doesn't support LIMIT clause on DELETE statement, but it can be available if sqlite is compiled with a custom option ([https://sqlite.org/compile.html#enable_update_delete_limit])

Tool might support this clause for UPDATE or DELETE statements, also it might generate a warning message about this usage instead of ignoring the query.

Relevant log output

# package db
error parsing queries: no queries contained in paths /home/<sqlc config path>/query.sql

Database schema

CREATE TABLE challenges (
        status TEXT
);

SQL queries

-- name: DeleteChallenge :exec
DELETE FROM challenges WHERE status = ? LIMIT 1;

Configuration

version: "2"
sql:
- schema: "schema.sql"
  queries: "query.sql"
  engine: "sqlite"
  gen:
    go:
      package: "db"
      out: "db"

Playground URL

https://play.sqlc.dev/p/031d55af21ebcebb19764888c1f2056714e6e48681930286d0841d2740ce20a6

What operating system are you using?

Linux

What database engines are you using?

No response

What type of code are you generating?

Go

@leobrines leobrines added bug Something isn't working triage New issues that hasn't been reviewed labels May 28, 2023
@kyleconroy kyleconroy added 🔧 golang 💻 linux 📚 sqlite and removed triage New issues that hasn't been reviewed labels Jun 6, 2023
@kyleconroy kyleconroy changed the title It doesn't detect DELETE statements when they contain a LIMIT clause on sqlite engine DELETE statements with a LIMIT do not work Jun 6, 2023
@kyleconroy kyleconroy added this to the v1.19.0 milestone Jun 6, 2023
@Jille
Copy link
Contributor

Jille commented Jun 24, 2023

I laid some groundwork for this in #2365, but the sqlite parser needs to be changed to accept it and pass it to the sqlc ast.

@Jille
Copy link
Contributor

Jille commented Jun 24, 2023

To clarify: after #2365 this does work in MySQL, but not yet in sqlite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants