Skip to content

deleteMany fails due to following findMany #1998

Closed
@platon-ivanov

Description

@platon-ivanov

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions