GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — sqlite: aliases in RETURNING are ignored when naming result columns · Issue #4680 · sqlc-dev/sqlc Labels bugSomething isn't workingSomething isn't working DescriptionVersion1.31.1 What happened?On the SQLite engine, aliases in a INSERT INTO t (name, score) VALUES (?, ?) RETURNING id AS new_id, score * 2 AS doubled; type InsertReturningRow struct { ID int64 // expected: NewID Column2 int64 // expected: Doubled } SQLite itself reports the column names This affects
The generated code compiles and runs, but the field names do not match the SQL. If the alias is added later, every caller breaks. Two aliases on the same column can't be told apart ( Relevant log outputDatabase schemaCREATE TABLE t ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, score INTEGER NOT NULL, created TEXT ); CREATE UNIQUE INDEX t_name ON t (name); SQL queries-- name: InsertReturningAlias :one INSERT INTO t (name, score) VALUES (?, ?) RETURNING id AS new_id, score * 2 AS doubled; -- name: UpsertReturningAlias :one INSERT INTO t (name, score) VALUES (?, ?) ON CONFLICT (name) DO UPDATE SET score = score + excluded.score RETURNING id AS new_id, score AS total; -- name: UpdateReturningAlias :many UPDATE t SET score = ? WHERE name = ? RETURNING id AS updated_id, score - 1 AS previous; -- name: DeleteReturningAlias :many DELETE FROM t WHERE score < ? RETURNING id AS deleted_id, upper(name) AS shout; Configurationversion: "2" sql: - engine: "sqlite" schema: "schema.sql" queries: "query.sql" gen: go: package: "db" out: "db" Playground URLNo response What operating system are you using?Linux What database engines are you using?SQLite What type of code are you generating?Go ActivityMetadataMetadataAssigneesLabelsbugSomething isn't workingSomething isn't working TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |