Mykyta Machekhin
06/15/2021, 8:53 PMupsert is non-transactional. After completing many upsert asynchronously, one of the call fell with a uniqueness error. That is, as I understand it, the prisma first run a select, and there is no record. Then value from other call writing down in a DB, after that the prisma tried to write down value, believing that it is not present in a DB that ended with an error
Is this expected behavior? If so, can this point be recorded in the documentation? And the main question - how can we simulate an upsert transactionally?Ryan
06/16/2021, 4:53 AMupsert is transactional as you can see by enabling the query log and in the screenshot I posted:
const prisma = new PrismaClient({
log: ['query'],
})Ryan
06/16/2021, 4:58 AMconst users = [1, 2, 1, 4, 5].map((val) =>
prisma.user.upsert({
create: { email: `user${val}`, name: `user${val}` },
update: { name: `user${val}` },
where: { id: val },
})
)
await Promise.all(users)Mykyta Machekhin
06/16/2021, 2:43 PMupsert (checked several times that it is that set of fields)Mykyta Machekhin
06/16/2021, 2:44 PMRyan
06/17/2021, 5:29 AM