Prisma Generator Returns "Unknown" for Postgres JSON
Closed this issue · 2 comments
seanemmer commented
Kysely: 0.27.3
Prisma Kysely: 1.8.0
Prisma: 5.8.1
Prisma Schema:
model Transaction {
id String
data Json?
}
Kysely Generator Config:
generator kysely {
provider = "prisma-kysely"
}
Kysely Generator Output:
export type Transaction = {
id: string
data: unknown | null
}
Expected Output (consistent with Prisma Client):
export type Transaction = {
id: string
data: Prisma.JsonValue | null
}
xxtanisxx commented
I was able to override it like this
/// @kyselyType(JSONColumnType<{login_at: string;ip: string | null;agent: string | null;}> | null)
However, i'll need to manually modify the import to add JSONColumnType
through VSCode
valtyr commented
As prisma-kysely isn't coupled to the Prisma client itself we can't promise any specific type for a JSON field. You can however use one of the many type override methods specified in the readme to achieve this.
Here's an example that should work:
generator kysely {
provider = "prisma-kysely"
jsonTypeOverride = "import('@prisma/client').Prisma.JsonValue"
}
Or explicitly specified per-field:
/// @kyselyType( import('@prisma/client').Prisma.JsonValue )