Skip to content

PostgreSQL ARRAY_AGG is not interpreted as an array. #3238

Open
@majimaccho

Description

@majimaccho

Thank you for great liberally.
I'm currently prototyping with sqlc-gen-typescript and I'm already big fan of it!

Then, I faced an issue with aggregation function ARRAY_AGG of PostgreSQL.
https://www.postgresql.org/docs/16/functions-aggregate.html

ARRAY_AGG returns array but the generated code for it is not array.

For example, when I have a table and query as below,

-- schema.sql 
CREATE TABLE table_a (
  id TEXT NOT NULL,
  column_a INT NOT NULL,
  column_b TEXT NOT NULL
)
;
-- name ListTableAGroupByCloumnB :many
SELECT ARRAY_AGG(column_b) as column_b_array
FROM table_a
GROUP BY column_a
;

The expected type of return value of this function should be like below.

export interface ListTableAGroupByCloumnBRow {
    column_b_array: string[]
}

However, current output would be as below.

export interface ListTableAGroupByCloumnBRow {
    column_b_array: string
}

Thank you for your help and thank you for your amazing work for this tool until now!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions