Skip to content

Sqlite engine creates wrong number of arguments in case of several JOINS with parameters #2368

Closed
@leodeim

Description

@leodeim

Version

1.18.0

What happened?

If you have a query with two JOINs which have parameters sqlite engine skips parameter in one of the JOINs.
If you change sqlite to mysql generation works correctly.
Schema, query and playground link are provided.

Relevant log output

No response

Database schema

CREATE TABLE authors (
  id   integer PRIMARY KEY,
  name text      NOT NULL,
  age  integer
);

CREATE TABLE translators (
  id   integer PRIMARY KEY,
  name text      NOT NULL,
  age  integer
);

CREATE TABLE books (
  id   integer PRIMARY KEY,
  author text      NOT NULL,
  translator text      NOT NULL,
  year  integer
);

SQL queries

DELETE FROM
  books AS b
WHERE
  b.author NOT IN (
    SELECT
      a.name
    FROM
      authors a
    WHERE
      a.age >= ?
  )
  AND b.translator NOT IN (
    SELECT
      t.name
    FROM
      translators t
    WHERE
      t.age >= ?
  )
  AND b.year <= ?;

Configuration

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

Playground URL

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

What operating system are you using?

Windows

What database engines are you using?

SQLite

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions