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 — duckdb: `SELECT * EXCLUDE (...)` and `* REPLACE (...)` give one untyped column and no error · Issue #4660 · sqlc-dev/sqlc Open DescriptionVersion
What happened?
Expected: either the remaining columns with their names and types, or an error at generate time. What DuckDB v1.5.6 reports ( Cause
Reproductionrepro6.sh (needs Go 1.27+ and a C compiler)#!/usr/bin/env bash # Needs Go 1.27+ and a C compiler (duckdb-go v2.10506.0). rm -rf repro6 && mkdir repro6 && cd repro6 cat > sqlc.yaml <<'EOF' version: "2" sql: - engine: "duckdb" schema: "schema.sql" queries: "query.sql" gen: go: package: "repro" out: "out" EOF cat > schema.sql <<'EOF' CREATE TABLE people (id INTEGER NOT NULL, name VARCHAR NOT NULL, secret VARCHAR, age INTEGER); EOF echo "== what sqlc analyze reports" for q in 'SELECT * EXCLUDE (secret) FROM people;' 'SELECT * FROM people;'; do printf -- '-- name: Q :many\n%s\n' "$q" > query.sql echo "-- $q"; sqlc analyze --dialect duckdb --schema schema.sql query.sql | grep -E '"name"' | grep -v '"name": "Q"' done echo; echo "== what sqlc generate does" printf -- '-- name: Q :many\nSELECT * EXCLUDE (secret) FROM people;\n' > query.sql rm -rf out; sqlc generate 2>&1 | grep -E 'error generating code' | head -2 if [ -f out/query.sql.go ]; then echo "generated: $(grep -E '^func \(q \*Queries\) Q' out/query.sql.go | sed 's/^func (q \*Queries) //')" cat > main.go <<'EOF' package main import ( "context" "database/sql" "fmt" _ "github.com/duckdb/duckdb-go/v2" "example.com/repro/out" ) func main() { db, _ := sql.Open("duckdb", "") db.SetMaxOpenConns(1) defer db.Close() db.Exec(`CREATE TABLE people (id INTEGER NOT NULL, name VARCHAR NOT NULL, secret VARCHAR, age INTEGER); INSERT INTO people VALUES (1, 'a', 's', 10);`) var cols int _ = db.QueryRow("SELECT count(*) FROM (DESCRIBE SELECT * EXCLUDE (secret) FROM people)").Scan(&cols) fmt.Println("DuckDB returns columns:", cols) _, err := repro.New(db).Q(context.Background()) fmt.Println("generated Q():", err) } EOF printf 'module example.com/repro\n\ngo 1.27\n' > go.mod go get github.com/duckdb/duckdb-go/[email protected] >/dev/null 2>&1 go mod tidy >/dev/null 2>&1 go run . fi Output with the Why there is no patchA real fix needs the exclude and replace lists to travel from the converter, through the AST, to Relevant log output== what sqlc analyze reports -- SELECT * EXCLUDE (secret) FROM people; "name": "?column?" -- SELECT * FROM people; "name": "id", "name": "integer" "name": "name", "name": "varchar" "name": "secret", "name": "varchar", "name": "age", "name": "integer", == what sqlc generate does error generating code: source error: 42:13: illegal character U+003F '?' (and 10 more errors) Database schemaCREATE TABLE people (id INTEGER NOT NULL, name VARCHAR NOT NULL, secret VARCHAR, age INTEGER); SQL queriesSELECT * EXCLUDE (secret) FROM people; SELECT * REPLACE (age + 1 AS age) FROM people; SELECT * FROM people; -- works Configurationversion: "2" sql: - engine: "duckdb" schema: "schema.sql" queries: "query.sql" gen: go: package: "repro" out: "out" Playground URLNot available. play.sqlc.dev runs only v1.18.0–v1.25.0, and the DuckDB engine is not in a release (v1.25.0 answers What operating system are you using?Linux What database engines are you using?(none of the listed options; the engine is duckdb) What type of code are you generating?Go RelatedRelated: #4657 (the ActivityMetadataMetadataAssigneesLabelsNo labels 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. |