Have this situation: ```let details: JsonValue | ...
# orm-help
d
Have this situation:
Copy code
let details: JsonValue | Prisma.DbNull = Prisma.DbNull;

// object.details is JsonValue
object.details = details === Prisma.DbNull ? null : details;

// Error: Type 'JsonValue | DbNull' is not assignable to type 'JsonValue'.
// Type 'DbNull' is not assignable to type 'JsonValue'
I don't see Prisma acknowledging this in documentation anywhere.
Copy code
object.details = details instanceof Prisma.NullTypes.DbNull ? null : details;

// This works ^^^
Not sure I like the version that works for TypeScript. Thoughts?
💬 1
1
v
👋 Hey @David Ilizarov - as a side note - I've asked our Docs team to confirm if we don't have this document and if they can provide some clarity Have you perhaps had a chance to review this doc: https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values I believe you would need to use
JsonNull
in this case Any comments/opinions from the Community, while I investigate are welcome! 😊
@David Ilizarov I have a bit more information for you here! This is how it used to work before
4.0.0
Copy code
import { PrismaClient, Prisma } from ".prisma/client"

let detail: Prisma.JsonValue | typeof Prisma.DbNull = Prisma.DbNull
let detail2: Prisma.JsonValue

detail2 = detail === Prisma.DbNull ? null : detail
After
4.0.0
,
instanceof
is the way to go:
Copy code
import { PrismaClient, Prisma } from ".prisma/client"

let detail: Prisma.JsonValue | typeof Prisma.DbNull = Prisma.DbNull
let detail2: Prisma.JsonValue

detail2 = detail instanceof Prisma.DbNull ? null : detail
You can also find more information here: Improve the UX of null values with JSON fields. Ultimately, we agree this is a confusing area and want to fix it! 😊
d
Oh cool — I see you all are aware that there are quirky issues that should be looked into. Good luck!
🙌 1
👍 1
v
Thank you! 😅 🤞