You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description and expected behavior
The problem is that zenstack is having some kind of problem of upserting relations when the where part of the upsert is using a compound/ unique key. With an unenhanced client it works as expected. Also when using the normal PrimaryKey it also work as expected, just in this scenario using unique keys is broken.
To recreate this behaviour use this code:
import "../../../prisma/zmodel/auth/user.zmodel"
model Test {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
linkingTable LinkingTable[]
key String @default('test')
locale String @default('EN')
@@schema("public")
@@map("test")
@@unique([key, locale])
@@allow("all", true)
}
model LinkingTable {
test_id String @db.Uuid
test Test @relation(fields: [test_id], references: [id])
another_test_id String @db.Uuid
another_test AnotherTest @relation(fields: [another_test_id], references: [id])
@@id([test_id, another_test_id])
@@map("__linking_table")
@@schema("public")
@@allow("all", true)
}
model AnotherTest {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
status String
linkingTable LinkingTable[]
@@schema("public")
@@map("another_test")
@@allow("all", true)
}
Description and expected behavior
The problem is that zenstack is having some kind of problem of upserting relations when the where part of the upsert is using a compound/ unique key. With an unenhanced client it works as expected. Also when using the normal PrimaryKey it also work as expected, just in this scenario using unique keys is broken.
To recreate this behaviour use this code:
The responding error message is:
Debug log also says:
Environment:
The text was updated successfully, but these errors were encountered: