```model SomeModel { id St...
# prisma-client
m
Copy code
model SomeModel {
  id                       String                    @id @default(uuid())
  name                     String
  SomeRelation             SomeRelation?             @relation(fields: [someRelationId], references: [id], onDelete: SetNull)
  someRelationId           String?
Hi, I was wondering if anyone can assist me with the following: I have a schema (similar to the one above) where the fk to SomeRelation is optional. In my "updateSomeModel" command - I am not allowed to update
{someRelationId: null}
even though the field is "nullable". This is problematic due to differentiating between removing an existing value and "not updating" if not set already. Is there a way to update to null on this kind of field?
1
👀 1
a
Hey there 👋! This should definitely be possible and it works for me when I try it with your schema. Have you re-ran
npx prisma generate
? Are you getting specific errors you can share?
m
Hey Austin, thank you for replying 🙂 I forgot to specifiy that the problem arises when updating a not-previously set field to null - it works well when someRelationId already has a value. I will recreate the error and come back to you with the error message. Arguably I shouldn't update the field when it already has the desired value, but it would allow my implementation to "not care" about the different scenarios.
Copy code
Foreign key constraint failed on the field: `SomeRelation_someRelationId_fkey (index)`
@Austin This was user error. Sorry to have wasted your time. Everything worked as it should prisma rainbow
🚀 1