According to the Prisma Typescript definition for atomic operations, we have:
export type IntFieldUpdateOperationsInput = {
set?: number
increment?: number
decrement?: number
multiply?: number
divide?: number
}
Let's take a look at the Prisma Schema:
model SomeEntity {
id Int @id @default(autoincrement())
quantity Int
}
We're dealing with a variable that could be either a number or undefined:
const someQuantity:number|undefined = undefined
Now, if we intend to update the 'quantity' field with this variable, our code might look like this:
const client = new PrismaClient();
client.someEntity.update({ where: { id: 1 }, data:{ quantity:{ increment: someQuantity }}})
If someQuantity===undefined
, Prisma throws an Error:
[ERROR] 09:47:48 Error: Invalid `prisma.someEntity.update()` invocation:
This seems counterintuitive based on the type signature. We are using Prisma version 2.28.0
and a Postgres DB
. Could there be a missing configuration or is it potentially a bug that needs reporting?