-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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
Labels
bugSomething isn't workingSomething isn't working