Skip to content

duckdb: a list-of-STRUCT column is generated as duckdb.Composite[[]map[string]any] instead of a slice of a generated struct #4715

Backlog

Description

@kyleconroy

Version

main at commit 3ad8b20 (2026-10-23). sqlc version prints v1.31.1.

What happened?

A STRUCT(...)[] column becomes duckdb.Composite[[]map[string]any] in the model. The struct's field names and types are in the schema, so sqlc could generate a Go struct for the element and type the column as a slice of it, for example:

type TransactionsItem struct {
	Type   sql.NullString
	Amount sql.NullInt32
}

type Transaction struct {
	ID    string
	Items duckdb.Composite[[]TransactionsItem]
}

Callers today have to type-assert every field out of map[string]any.

Workaround: flatten the list into its own view or query (unnest and extract each field with a CAST), so no struct reaches Go.

Generated code

type Transaction struct {
	ID    string
	Items duckdb.Composite[[]map[string]any]
}

Database schema

CREATE TABLE transactions (id VARCHAR NOT NULL, items STRUCT(type VARCHAR, amount INTEGER)[]);

SQL queries

-- name: ListTransactions :many
SELECT id, items FROM transactions;

Configuration

version: "2"
sql:
  - engine: duckdb
    schema: schema.sql
    queries: query.sql
    gen:
      go:
        package: db
        out: db

What operating system are you using?

Linux

What database engines are you using?

DuckDB

What type of code are you generating?

Go

Activity

  1. added
    enhancement
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions