Open cytown opened 1 month ago
Similar problem here, but with a different input:
1.26.0
# package db
queries/queries.sql:5:7: column reference "id" is ambiguous
From playground:
sqlc generate failed.
2024/08/08 15:33:36 sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext
2024/08/08 15:33:36 sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext
2024/08/08 15:33:36 sqlite.convert(case=default): Unknown node type *parser.Expr_unaryContext
# package
query.sql:5:7: column reference "id" is ambiguous
CREATE TABLE IF NOT EXISTS USERS (
ID INTEGER PRIMARY KEY,
DOCUMENT INTEGER,
REMOVED_AT TEXT,
FOREIGN KEY (DOCUMENT) REFERENCES DOCUMENTS (ID)
);
CREATE TABLE IF NOT EXISTS DOCUMENTS (
ID INTEGER PRIMARY KEY,
REMOVED_AT TEXT
);
-- name: RemoveDocument :execrows
UPDATE DOCUMENTS
SET
removed_at = CURRENT_TIMESTAMP
WHERE id = ?1
AND removed_at IS NULL
AND id NOT IN (SELECT document FROM USERS WHERE document IS NOT NULL);
version: "2"
sql:
- engine: "sqlite"
queries: "./queries"
schema: "./migrations"
gen:
go:
out: "."
package: "db"
https://play.sqlc.dev/p/906eac25119af6f519b77983cfe4a67e5aa41465e76dbcdbe08af6c8b5b033e3
Linux
SQLite
Go
Version
1.26.0
What happened?
First time I tried field name "id" in both table, it's very common in realworld, but it said "id" is ambiguous, so I change the id to bid in second table, but still get wrong...
Also tried sqlc.args(xxx), but will failed either.
For your reference, the sql clause should not failed.
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/3ef93462e0cc926c18e7d79bbdd1ce8239fe3b1c4afed1026cd357502a8c7adf
What operating system are you using?
Linux, macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go