does null get overlooked during prisma update

Example
await ctx.prisma.user.update{
data: {
...input
age: input.age ? input.age : null
position: input.position ? input.position : null
}
}
await ctx.prisma.user.update{
data: {
...input
age: input.age ? input.age : null
position: input.position ? input.position : null
}
}
So basically my questions are 1) if age already has a value and input.age doesn't have any value will this override what's there and put null or prisma will skip the update of age because null was provided 2) if undefined or null is provided will this trigger an update or prisma is smart enough to skip it?
4 Replies
Lopen
Lopen2y ago
3) during prisma create if an empty string is provided will that crate an empty field or prisma is smart enough to put null?
word
word2y ago
I was testing this today and as far as I've seen Prisma will put null.
word
word2y ago
For Prisma null is a value, so it will override. Check this: https://www.prisma.io/docs/concepts/components/prisma-client/null-and-undefined
Prisma
Null and undefined (Reference)
How Prisma Client handles null and undefined, including a GraphQL use case.
Brendonovich
Brendonovich2y ago
1) Yes, it will override. null is a proper value accepted by Prisma so it will override. Use undefined if you want Prisma to ignore it. 2) If it's undefined then the query engine will ignore it, yes 3) An empty string means a very different thing to Prisma and your db than null, so it will put that empty string as the value
Want results from more Discord servers?
Add your server