Prisma1: prisma updateMany execution order issue

Created on 5 Jan 2019  路  8Comments  路  Source: prisma/prisma1

I have a question regarding prisma client updateMany. We use it to wrap deletions from two tables into one transaction, we also want to delete the relation between them. We are soft deleting so what we do is actually update TableA, updateMany TableB, and disconnect TableB. It turns out when we have both disconnect and updateMany in the same data object, the updateMany will be ignored. It seems there is some internal priorities and the disconnect was executed first? Is it a design choice or is it a bug? Thx!

kinfeature areserver

Most helpful comment

@xiaoqf10 : 馃憢
I digged into our code base and it indeed looks like we are executing the disconnect first. This line should be the one determining the execution order.

All 8 comments

cc @mavilein

Hi, @xiaoqf10 Can you provide me with the part of the datamodel and the queries you are making so that I can reproduce this?

Update: I tried to reproduce this myself and was successful:

mutation {
  updateUser(
    data: {
      organisations: {
        disconnect: { id: "cjqwhotlv000c0907wkcjp1l7" }
        updateMany: {
          where: { id: "cjqwhotlv000c0907wkcjp1l7" }
          data: { name: "Jsaf" }
        }
      }
    }
    where: { id: "cjqwhotnm000d0907vhvmf0pr" }
  ) {
    id
  }
}

But when I query users:

{
  users {
    id
    organisations {
      name
      id
    }
  }
  organisations{
    id
    name
  }
}

{
  "data": {
    "users": [
      {
        "id": "cjqwhotnm000d0907vhvmf0pr",
        "organisations": []
      }
    ],
    "organisations": [
      {
        "id": "cjqwhotlv000c0907wkcjp1l7",
        "name": "Prisma"
      }
    ]
  }
}

Here is the reproduction repo: https://github.com/pantharshit00/prisma-issue-3811

@xiaoqf10 : 馃憢
I digged into our code base and it indeed looks like we are executing the disconnect first. This line should be the one determining the execution order.

@mavilein Is this bug fixed?

@xiaoqf10 : No we did not take any action on this yet. Is this your only requirement in regards to the execution order? If you have other requirements please list them out. 馃檹

Turning this into a feature request which would enable controlling the execution order of a single query.

+1, What is the plan? Looks like it's a bug

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

MitkoTschimev picture MitkoTschimev  路  3Comments

marktani picture marktani  路  3Comments

schickling picture schickling  路  3Comments

marktani picture marktani  路  3Comments