Skip to content

Typegen fails on unnest #413

@tbillington

Description

@tbillington

Typegen fails on call with unnest. The output is Query is not typeable.

I would expect that in this case the types in the where clause should not matter to the typegen, since the columns are pulled straight from a table, not based on anything to do with the unpacked rows.

When I remove the where clause, the query typegens successfully.

slonik

const pairs: [string, string][] = ...;
sql`
select
  col_a,
  col_b,
  col_c
from
  data_table
where
  (col_a, col_b)
  = ANY(select col_a, col_b from ${sql.unnest(pairs, [
    'text',
    'text',
  ])})
`

generated sql

select
    col_a,
    col_b,
    col_c
from
    data_table
where
    (col_a, col_b)
    = ANY(select col_a, col_b from unnest($1::"text"[], $2::"text"[]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions