diff --git a/packages/schema/src/res/stdlib.zmodel b/packages/schema/src/res/stdlib.zmodel index 222765a29..1bcae635e 100644 --- a/packages/schema/src/res/stdlib.zmodel +++ b/packages/schema/src/res/stdlib.zmodel @@ -505,8 +505,8 @@ attribute @db.Timetz(_ x: Int?) @@@targetField([DateTimeField]) @@@prisma // Json type modifiers -attribute @db.Json() @@@targetField([JsonField]) @@@prisma -attribute @db.JsonB() @@@targetField([JsonField]) @@@prisma +attribute @db.Json() @@@targetField([JsonField, TypeDefField]) @@@prisma +attribute @db.JsonB() @@@targetField([JsonField, TypeDefField]) @@@prisma // Bytes type modifiers diff --git a/tests/integration/tests/enhancements/json/typing.test.ts b/tests/integration/tests/enhancements/json/typing.test.ts index 99869accd..607daa54f 100644 --- a/tests/integration/tests/enhancements/json/typing.test.ts +++ b/tests/integration/tests/enhancements/json/typing.test.ts @@ -385,4 +385,37 @@ async function main() { } ); }); + + it('supports @db.Json and @db.JsonB', async () => { + await loadSchema( + ` + type Profile { + age Int @gt(0) + } + + model User { + id Int @id @default(autoincrement()) + profile Profile @json @db.Json + posts Post[] + @@allow('all', true) + } + + type Meta { + description String + } + + model Post { + id Int @id @default(autoincrement()) + title String + user User @relation(fields: [userId], references: [id]) + userId Int + meta Meta @json @db.JsonB + } + `, + { + provider: 'postgresql', + pushDb: false, + } + ); + }); });