Skip to content

DELETE statements with a LIMIT do not work #2291

Closed
@leobrines

Description

@leobrines

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions