-
Notifications
You must be signed in to change notification settings - Fork 929
Open
Labels
Description
Version
1.29.0
What happened?
Writing a query that uses the form:
SELECT
col1,
col2,
...
WHERE NOT EXISTS (
SELECT 1 FROM "table" WHERE "table"."id" = sqlc.arg('tableId')
);
Will copy over the expr after the WHERE as is, and neither replace the sqlc.arg
with a placeholder nor extract that arg as a param for the query.
Relevant log output
N/A
Database schema
CREATE TABLE IF NOT EXISTS "rels" (
"id" text PRIMARY KEY NOT NULL,
"type" integer NOT NULL,
"left" text NOT NULL,
"right" text NOT NULL,
"metadata" blob,
"created" integer NOT NULL
) STRICT;
SQL queries
-- name: InsertPostReact :exec
INSERT INTO "rels" (
id,
type,
left,
right,
metadata,
created
)
SELECT
sqlc.arg('id'),
sqlc.arg('type'),
sqlc.arg('left'),
sqlc.arg('right'),
sqlc.arg('metadata'),
sqlc.arg('created')
WHERE NOT EXISTS (
SELECT
1
FROM
"rels"
WHERE
"rels"."left" = sqlc.arg('left') AND
"rels"."right" = sqlc.arg('right') AND
"rels"."type" = sqlc.arg('prohibitedType')
)
LIMIT 1;
Configuration
version: "2"
sql:
- engine: "sqlite"
queries: "db/query.sql"
schema: "db/schema.sql"
gen:
go:
package: "dbv2"
out: "dbv2"
Playground URL
https://play.sqlc.dev/p/1a0e77fe8d04f6cd64fa7f794c4d5a2a133730ab653dded3989f268ba7192819
What operating system are you using?
macOS
What database engines are you using?
SQLite
What type of code are you generating?
Go