Skip to content

deleteMany fails due to following findMany #1998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
platon-ivanov opened this issue Feb 21, 2025 · 2 comments
Closed

deleteMany fails due to following findMany #1998

platon-ivanov opened this issue Feb 21, 2025 · 2 comments

Comments

@platon-ivanov
Copy link

Description and expected behavior
Hello! When running query like this:

await prisma.relation.deleteMany({
  where: {
    OR: relationChanges,
    },
})

I get the following error:

Invalid `prisma.relation.delete()` invocation:

{
  where: {
    parentId: "_dxnoE",
    childId: "FmXWov",
?   parentId_childId?: RelationParentIdChildIdCompoundUniqueInput,
?   AND?: RelationWhereInput | RelationWhereInput[],
?   OR?: RelationWhereInput[],
?   NOT?: RelationWhereInput | RelationWhereInput[],
?   parent?: EntityScalarRelationFilter | EntityWhereInput,
?   child?: EntityScalarRelationFilter | EntityWhereInput
  }
}

Argument `where` of type RelationWhereUniqueInput needs at least one of `parentId_childId` arguments. Available options are marked with ?.

So I update the query:

prisma.relation.deleteMany({
  where: {
    OR: relationChanges.map((rel) => ({
      parentId_childId: rel,
    })),
  },
})

Now I get a whole different error:

Invalid `prisma.relation.findMany()` invocation:
Unknown argument `parentId_childId`. Available options are marked with ?.

The schema:

model Relation {
  parent   Entity @relation("children", fields: [parentId], references: [id])
  parentId String
  child    Entity @relation("parents", fields: [childId], references: [id])
  childId  String

  @@allow('read', check(parent, 'read') && check(child, 'read'))
  @@allow('create,delete', check(parent, 'update') && check(child, 'update'))

  @@id([parentId, childId])
}

Environment:

  • ZenStack version: 2.11.6
  • Prisma version: 6.3.1
  • Database type: Postgresql
@ymc9
Copy link
Member

ymc9 commented Feb 23, 2025

Hi @platon-ivanov , thanks for filing this. Could you share the full model and the value of relationChange in the deleteMany body? I tried to reproduce the issue bug haven't succeeded yet. I suspect it's related to polymorphic models but not sure if you're using it.

Or if you have a repro project it'd be great.

@ymc9
Copy link
Member

ymc9 commented Feb 23, 2025

Never mind. I've got a repro 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants