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: a result column without a name is called `?column?`, which is not valid Go · Issue #4657 · sqlc-dev/sqlc Open DescriptionVersion
What happened?A result column with no alias, that is not a plain column and not a function call, gets the name The PostgreSQL and SQLite engines name such a column What DuckDB v1.5.6 reports ( Expected: a valid Go name ( Cause
Reproductionrepro3.sh#!/usr/bin/env bash rm -rf repro3 && mkdir repro3 && cd repro3 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, age INTEGER); EOF while IFS= read -r q; do printf -- '-- name: Q :many\n%s\n' "$q" > query.sql; rm -rf out echo "== $q" sqlc generate 2>&1 | grep -E 'error generating code|var \?column\?' | head -3 [ -f out/query.sql.go ] && echo "generated OK: $(grep -E '^func \(q \*Queries\) Q' out/query.sql.go | sed 's/^func (q \*Queries) //')" done <<'EOF' SELECT CAST(age AS BIGINT) AS age FROM people; SELECT CAST(age AS BIGINT) FROM people; SELECT name || '!' FROM people; SELECT id + 1, age * 2 FROM people; SELECT upper(name) FROM people; EOF echo echo "== the name that sqlc analyze reports" printf -- "-- name: Q :many\nSELECT CAST(age AS BIGINT) FROM people;\n" > query.sql sqlc analyze --dialect duckdb --schema schema.sql query.sql | grep -E '"name"' | grep -v '"name": "Q"' FixI have a patch with an end-to-end test case, and I will open a pull request. RelatedWith this change, Relevant log output== SELECT CAST(age AS BIGINT) AS age FROM people; generated OK: Q(ctx context.Context) ([]sql.NullInt64, error) { == SELECT CAST(age AS BIGINT) FROM people; var ?column? sql.NullInt64 error generating code: source error: 43:13: illegal character U+003F '?' (and 10 more errors) == SELECT name || '!' FROM people; var ?column? string error generating code: source error: 42:13: illegal character U+003F '?' (and 10 more errors) == SELECT id + 1, age * 2 FROM people; generated OK: Q(ctx context.Context) ([]QRow, error) { == SELECT upper(name) FROM people; generated OK: Q(ctx context.Context) ([]string, error) { == the name that sqlc analyze reports "name": "?column?", "name": "bigint", Database schemaCREATE TABLE people (id INTEGER NOT NULL, name VARCHAR NOT NULL, age INTEGER); SQL queriesSELECT CAST(age AS BIGINT) AS age FROM people; -- works SELECT CAST(age AS BIGINT) FROM people; -- fails SELECT name || '!' FROM people; -- fails SELECT id + 1, age * 2 FROM people; -- works SELECT upper(name) 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: #4660 ( 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. |