sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.58k stars 812 forks source link

Parameters in DELETE FROM .. LEFT JOIN .. ON clause ignored #3630

Open Jille opened 1 month ago

Jille commented 1 month ago

Version

1.27.0

What happened?

It looks like sqlc doesn't understand parameters in the ON clause of a LEFT JOIN for a DELETE query. It does work for a SELECT query.

In the linked playground example, it creates a method with zero arguments instead of one.

Relevant log output

No response

Database schema

CREATE TABLE perma (
  instance CHAR(12) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  id INT UNSIGNED NOT NULL,
  PRIMARY KEY(instance, object_id)
);

CREATE TEMPORARY TABLE tempo (
  object_id INT UNSIGNED NOT NULL PRIMARY KEY
);

SQL queries

-- name: DeleteLeftJoin :exec
DELETE perma FROM perma LEFT JOIN tempo next ON tempo.object_id = perma.object_id AND perma.instance=? WHERE perma.id IS NULL ;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/36f3fa4197f27bbec82809617fb49cde4b8e7d099305b4686a8686c0def7b475

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go