I'm unable to nullify a many-to-one and update a o...
# prisma-client
y
I'm unable to nullify a many-to-one and update a one-to-one at the same time. Can someone please help? `Error: Unknown arg
team_id
in data.team_id for type PersonUpdateInput. Did you mean
team
?`
Copy code
model Person {
  id         Int    @id
  first_name String
  last_name  String
  team_id    Int?

  personData PersonData?
  team       Team?       @relation(fields: [team_id], references: [id])
}

model PersonData {
  person_id      Int    @id
  favorite_color String

  person Person @relation(fields: [person_id], references: [id])
}

model Team {
  id   Int    @id
  name String

  people Person[]
}
Copy code
await prisma.person.update({
  where: {
    id: 1,
  },
  data: {
    team_id: null,
    personData: {
      update: {
        favorite_color: 'Purple',
      },
    },
  },
});
👀 1
n
Hey Yaakov 👋 Here’s the query that I tried with your schema and it’s working as expected for me.
Copy code
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
  // Creating User

  await prisma.person.create({
    data: {
      first_name: 'John',
      last_name: 'Doe',
      personData: {
        create: {
          favorite_color: 'red',
        },
      },
      id: 1,
      team: {
        create: {
          id: 1,
          name: 'Team 1',
        },
      },
    },
  });

  await prisma.person.update({
    where: {
      id: 1,
    },
    data: {
      team_id: null,
      personData: {
        update: {
          favorite_color: 'Purple',
        },
      },
    },
  });
}

main()
  .catch((e) => {
    throw e;
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
What’s your prisma version? I tried this query on PostgreSQL database.
y
3.15.2
I'm curious why this is working for you.
n
And are you using PostgreSQL?
y
No, but that should not matter. This is a Prisma error that I'm getting.
n
Is your repository public or if you could provide a sample reproduction, I could check and see what’s going wrong in your case.