After upgrading to 3.0.2, can't create or update records when json field is null
See original GitHub issueI’m having a similar error to https://github.com/prisma/prisma/issues/9199 after upgrading to Prisma 3.0.2 (from 2.x)
I have also ran prisma migrate
with no changes in order to cohere with Upgrade Path for referential actions and named constraints
datamodel in particualar:
model Room {
id String @id @default(cuid()) @db.VarChar(30)
name String
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
accountId String @map("account") @db.VarChar(30)
bgColor Json?
account Account @relation(fields: [accountId], references: [id])
bookings Booking[]
@@index([accountId])
}
Mutation from Nexus:
t.field('createRoom', {
type: 'Room',
args: {
name: nonNull(stringArg()),
accountId: nonNull(idArg()),
bgColor: arg({type: "Json"}),
},
resolve: (_parent, args, ctx) => ctx.prisma.room.create({
data: {
...args
}
})
});
Error when bgColor is null (the same thing when creating or updating):
Invalid `prisma.room.create()` invocation: { data: { name: 'Test Room', accountId: 'ckm7v6zpi00130huil8hbwvlk', bgColor: null ~~~~ } } Argument bgColor for data.bgColor must not be null. Please use undefined instead.```
_Originally posted by @chemicalkosek in https://github.com/prisma/prisma/issues/9199#issuecomment-919430264_
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (3 by maintainers)
Top Results From Across the Web
JSON reader parses values as null - Azure Databricks
You are attempting to read a JSON file. You know the file has data in it, but the Apache Spark JSON reader is...
Read more >Migration Guide: SQL, Datasets and DataFrame - Spark 3.0.2 ...
In Spark 3.0, the returned row can contain non- null fields if some of JSON column values were parsed and converted to desired...
Read more >12 Updating a JSON Document with JSON Merge Patch
If a patch field value of null did not have a special meaning (remove the corresponding source member with that field) then you...
Read more >Upgrade to Prisma 3
You cannot filter a Json field by a null value. See this GitHub issue. This is because { equals: null } checks if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That would mean rewriting even the simplest resolvers such as
to check for json null values. Can we make a default that will transform the null value to the previous behaviour? Or such thing will not be possible?
Hey everyone, sorry for the confusion here. This is expected, but we missed this in our documentation. We stopped allowing nulls for JSON field inputs because:
The above code is ambiguous:
The solution is to use
DbNull
andJsonNull
. To insert anull
value into a Json field, you would write:And to insert a database
NULL
into a Json field, you would write:We’re going to improve this error message and also fix up our documentation.