Skip to content

A plain JS array of booleans, Dates, bigints or Buffers binds as a single value #45

Open

Description

@okomarov

Found while planning #41; not reproduced yet.

inferType types a JS array by its first element (src/types.js, Array.isArray(x) ? inferType(x[0])). For strings and numbers that is 0, so the server's reported array type picks the array serializer. For booleans, Dates, bigints and Buffers the element type is non-zero, so Parse declares the scalar type (for example boolean) for a value that is an array. The query fails or binds wrongly. Only sql.array(value) works today.

Expected: a plain JS array is declared as the matching array type (bool[], timestamptz[], int8[], bytea[]), or left untyped for the server to decide.

Reported upstream as porsager#471; proposed fixes porsager#1050, porsager#533 and porsager#1032. By reading, select ${ [true, false] }::bool[] fails with "cannot cast type boolean to boolean[]". The same inference breaks ${ true }::jsonb (#84).

Activity

  1. added
    bug
    on Oct 13, 2026
  2. moved this to Later in Roadmapon Oct 15, 2026
  3. added
    area: serialization
    on Oct 16, 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

    area: serializationbug

    Type

    No type

    Projects

    • Status
      Later

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions