Skip to content

Vectors (for pgvector) are not treated correctly #206

@MischaPanch

Description

@MischaPanch

Bug report

Describe the bug

When using a schema with vectors using the pgvector extension, the resulting SQL is syntactically incorrect.

To Reproduce

Setup a prisma schema like this

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions"]
}

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  directUrl  = env("DIRECT_URL")
  extensions = [pgvector(map: "vector", schema: "extensions")]
}

model MyEmbedding {
  id                 String                      @id @default(uuid()) @db.Uuid
  embedding          Unsupported("vector(8)")
  @@map["my_embeddings"]
}

Then creating entries with seed.myEmbedding will create invalid SQL. If an array [num1, num2, ...] is passed as value for embedding, the result is

INSERT INTO ... VALUES (<id>, num1, num2, ...)

The correct syntax is

INSERT INTO ... VALUES (<id>, ARRAY[num1, num2, ...]::vector)

I tried passing the string "ARRAY[num1, num2, ...]::vector" as value for embeddings. The sql then becomes

INSERT INTO ... VALUES (<id>, 'ARRAY[num1, num2, ...]::vector')

so it's almost correct, but not quite.

Expected behavior

The correct sql code is generated when vectors are passed, or some workaround for vectors is possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions