Skip to content

postgresql: ARRAY(SELECT ...) is generated as interface{} and unaliased column is named "exists" #4728

Backlog

Description

@takiren

Version

1.31.1

What happened?

In the PostgreSQL engine, an ARRAY(SELECT ...) expression has two problems:

  1. The result column is generated as interface{} instead of a slice of the subquery's column type.
  2. When the column has no alias, it is named exists (and the Go field becomes Exists), but PostgreSQL names it array.

Relevant log output

Database schema

CREATE TABLE singers (id bigserial PRIMARY KEY);
CREATE TABLE albums (
  id bigserial PRIMARY KEY,
  singer_id bigint NOT NULL REFERENCES singers (id)
);

SQL queries

-- name: ListSingerAlbums :many
SELECT id, ARRAY(SELECT albums.id FROM albums WHERE albums.singer_id = singers.id) AS album_ids
FROM singers;

-- name: ListSingerAlbumsNoAlias :many
SELECT ARRAY(SELECT albums.id FROM albums WHERE albums.singer_id = singers.id)
FROM singers;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "go",
      "engine": "postgresql",
      "sql_package": "pgx/v5",
      "name": "querytest",
      "schema": "schema.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Activity

  1. added
    bug
    on Dec 2, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions