Skip to content

multiple identical compound unique fields with different types not generating multiple types #4454

@PHILLIPS71

Description

@PHILLIPS71

Bug description

I've got 2 models with the following structure, both use the same unique field mapping on type and token, but use different enum types. There is only 1 type generated for these compounded fields (or the other is overridden), but it's causing typescript to complain when querying via the compounded unique fields since the types are incorrect.

model Token {
  id         String    @id @default(cuid())
  type       TokenType
  token      String
  created_at DateTime  @default(now())
  updated_at DateTime  @updatedAt

  @@unique([type, token])
}

model UserCredential {
  id         String         @id @default(cuid())
  type       CredentialType
  token      String         @unique
  created_at DateTime       @default(now())
  updated_at DateTime       @updatedAt

  user    User   @relation(fields: [user_id], references: [id])
  user_id String

  @@unique([type, token])
}

Generated Type

  export type TypeTokenCompoundUniqueInput = {
    type: CredentialType
    token: string
  }

How to reproduce

Create two models with the same compounded unique constraints that both share the same name then run prisma generate

Expected behaviour

I'd expect two types to be exports, one for each of the compounded unique constraints that follow the correct types

Environment & setup

  • OS: Windows
  • Database: PostgreSQL
  • Node.js version: v12.16.2
  • Prisma version: 6.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions