Skip to content

Bug Report: Inserting String[] field causes Postgres malformed array literal error #2474

@motopods

Description

@motopods

Description and expected behavior
When inserting a record containing a String[] field using ZenStack ORM with PostgreSQL, the query fails with:

malformed array literal

The ORM appears to send a single string instead of a PostgreSQL array literal.

Schema Example

Example model:

model OrderRecord {
  id        String   @id @default(cuid())
  userId    String
  status    String
  tags      String[]
  createdAt DateTime @default(now())
}

The tags field is defined as String[].


Insert Code

Example insert:

await db.orderRecord.create({
  data: {
    userId: "user_123",
    status: "PENDING",
    tags: ["example_tag"],
  },
});

Generated SQL (from logs)

insert into "public"."OrderRecord"
("userId", "status", "tags", "id", "createdAt")
values ($1, $2, $3, $4, $5)
returning "id"

Parameters:

[
  "user_123",
  "PENDING",
  ["example_tag"],
  "rec_abc123",
  "2026-03-11T13:09:57.947Z"
]

Postgres Error

malformed array literal: "example_tag"

Full error log:

{
  "reason": "db-query-error",
  "dbErrorCode": "ERR_POSTGRES_SERVER_ERROR",
  "dbErrorMessage": "malformed array literal: \"example_tag\""
}

Expected Behavior

ZenStack should correctly serialize String[] into a PostgreSQL array.

Expected SQL parameter format:

{"example_tag"}

instead of:

"example_tag"

Environment (please complete the following information):

  • ZenStack version: 3.4.5
  • Database type: Postgresql
  • Node.js/Bun version: bun 1.3.10
  • Package manager: bun

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