Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
not-ani opened this issue Jan 25, 2025 · 0 comments
Open
1 task done

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

not-ani opened this issue Jan 25, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@not-ani
Copy link

not-ani commented Jan 25, 2025

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')
      )`,
    ),
  ],
);
@not-ani not-ani added the bug Something isn't working label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant