Skip to content

[BUG]: Postgres Error "malformed array literal" #4000

Description

@not-ani

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.38.3

What version of drizzle-kit are you using?

0.30.1

Other packages

No response

Describe the Bug

When I run drizzle-kit push, I get this error

[] Pulling schema from database...
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

PostgresError: malformed array literal: "{(setweight(to_tsvector('english'::regconfig, front), 'A'::"char") || setweight(to_tsvector('english'::regconfig, back), 'B'::"char"))}"
    at ErrorResponse (file:///Users/c/Production/ocw/node_modules/postgres/src/connection.js:788:26)
    at handle (file:///Users/c/Production/ocw/node_modules/postgres/src/connection.js:474:6)
    at TLSSocket.data (file:///Users/c/Production/ocw/node_modules/postgres/src/connection.js:315:9)
    at TLSSocket.emit (node:events:524:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:189:23) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '22P02',
  detail: 'Unexpected array element.',
  file: 'arrayfuncs.c',
  line: '546',
  routine: 'ArrayCount'
}

Node.js v22.12.0
error: script "db:push" exited with code 1

Here is the effect table:

export const easyNoteCard = createTable(
  "easy_note_card",
  {
    id: text("id")
      .primaryKey()
      .$defaultFn(() => createId()),
    front: text("front").notNull(),
    embedding: vector("embedding", { dimensions: 1536 }),
    options: text("options").array().notNull(),
    images: text("images").array(),
    unitId: text("unitId").notNull(),
    chapter: integer("chapter").notNull(),
    back: text("back").notNull(),
  },
  (t) => [
    index("embeddingIndex").using("hnsw", t.embedding.op("vector_cosine_ops")),
    index('search_index').using(
      'gin',
      sql`(
          setweight(to_tsvector('english', ${t.front}), 'A') ||
          setweight(to_tsvector('english', ${t.back}), 'B')
      )`,
    ),
  ],
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug/cant-reproduceLack steps to fully reproduce. A repository for reproduction may be necessarydb/postgresdrizzle/kitpriorityWill be worked on next

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions