Skip to content

Commit d652e12

Browse files
ankur-archclaude
andcommitted
docs(data-modeling): note explicit discriminator on variant creates (live-tested)
Verified against a fresh Prisma Postgres database: variant ORM roots exist and base queries return variant rows, but creating through a variant does not auto-fill the discriminator on 0.14.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 47363ad commit d652e12

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

apps/docs/content/docs/orm/next/data-modeling/relational-databases.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ model Feature {
190190

191191
`@@discriminator(type)` marks the field that records the variant. `@@base(Task, "bug")` declares that `Bug` is the `"bug"` variant of `Task`.
192192

193+
Variants appear as their own models in queries (`db.orm.public.Bug` alongside `db.orm.public.Task`), and a query on the base model returns every variant. One thing to know when writing: pass the discriminator value explicitly when you create through a variant (`{ title, severity, type: "bug" }`); it is not filled in automatically yet.
194+
193195
Each variant picks one of two storage layouts:
194196

195197
- A variant with no `@@map`, like `Bug`, shares the base table. Its extra columns live alongside the base columns and must be nullable at the storage level, because a `Feature` row has no severity.

0 commit comments

Comments
 (0)