Skip to content

UniqueCompundInput for partial unique index is generated #29282

@Rusty-Beard

Description

@Rusty-Beard

Bug description

Prisma generates UniqueCompoundInput for a unique partial index. A query can be executed, but acts like findFirst, which may not be expected.

Also, when an actual database contains partial indexes, prisma migration reset && prisma db pull produces previewFeatures = ["partialIndexes"] for each generator, but i expect it to be only for client generator

Severity

🔹 Minor: Unexpected behavior, but does not block development

Reproduction

  • Enable new 'partialIndexes' preview feature
  • Create a unique partial index, e.g. @@unique([field1, field2], where: raw("(\"field3\" IS NULL)"))

Expected vs. Actual Behavior

Expected: CompoundUniqueInput is not generated for a unique partial index.

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

No

Workaround

No workaround found

Prisma Schema & Queries

model Entity {
  id     String @id
  field1 String
  field2 String
  field3 String

  @@unique([field1, field2], where: raw("(\"field3\" IS NULL)"))
  @@schema("public")
}
await prisma.entity.findUnique({ where: { field1_field2: { field1: "", field2: "" } } })

Prisma Config

No response

Logs & Debug Info

No response

Environment & Setup

  • OS: Manjaro
  • Database: PostgreSQL
  • Node.js version: 24.13.1

Prisma Version

7.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions