Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/core/analyzer/projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func (a *analyzer) decorateSource(col *core.Column, attOID int64, tableAlias str

// targetName picks the output name for a target. fields is the already
// flattened field list when rt.Val is a column reference, and nil otherwise.
// A target with no name returns "", so code generation names it by position
// (column_1) as it does for the other engines. "?column?" is not a valid
// identifier in the generated code.
func targetName(rt *ast.ResTarget, fields []string) string {
if rt.Name != nil && *rt.Name != "" {
return *rt.Name
Expand All @@ -117,7 +120,7 @@ func targetName(rt *ast.ResTarget, fields []string) string {
return name
}
}
return "?column?"
return ""
}

func isStar(fields []string) bool {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"contexts": ["base"]}
31 changes: 31 additions & 0 deletions internal/endtoend/testdata/duckdb_unnamed_columns/duckdb/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions internal/endtoend/testdata/duckdb_unnamed_columns/duckdb/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- name: Cast :many
SELECT CAST(age AS BIGINT) FROM people;

-- name: Concat :many
SELECT name || '!' FROM people;

-- name: Two :many
SELECT id + 1, age * 2 FROM people;

-- name: Mixed :many
SELECT id, upper(name), age + 1 AS next_age, id * 2 FROM people;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE people (id INTEGER NOT NULL, name VARCHAR NOT NULL, age INTEGER);
10 changes: 10 additions & 0 deletions internal/endtoend/testdata/duckdb_unnamed_columns/duckdb/sqlc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "2"
sql:
- engine: "duckdb"
schema: "schema.sql"
queries: "query.sql"
gen:
go:
package: "querytest"
out: "go"
sql_package: "database/sql"
Loading