When I try to use @@unique it doesn't error and seems to be implemented in the engine but the generated code only show scalar fields.
When I use a relation as an @id or inside a @@unique as specified in these tests https://github.com/prisma/prisma-engines/commit/4108df5e6a678c1dc8637a9ae40e886064789d39 the generated code does not contain the relation fields in WhereUniqueInput, only scalar fields are present.
Is it a bug or is it only supported by the engine but not in the generated code?
Example with @@unique:
schema.prisma
model Company {
id String @default(uuid()) @id
name String
}
model Subside {
id String @default(uuid()) @id
company Company @relation(references: [id])
reference String
@@unique([company, reference])
}
Generated code
export type ReferenceCompoundUniqueInput = {
reference: string
}
export type SubsideWhereUniqueInput = {
id?: string | null
company_reference?: ReferenceCompoundUniqueInput | null
}
Example with @id:
schema.prisma
model Company {
id String @default(uuid()) @id
name String
}
model CompanyData {
id Company @relation(references: [id]) @id
someData String
}
Generated code doesn't contain any findOne, update, ... Only operations on many objects are generated.
Related to #306
This will be fixed by this internal work package: https://github.com/prisma/prisma-engines/issues/543
Example with
@@unique:schema.prisma
model Company { id String @default(uuid()) @id name String } model Subside { id String @default(uuid()) @id company Company @relation(references: [id]) reference String @@unique([company, reference]) }Generated code
export type ReferenceCompoundUniqueInput = { reference: string } export type SubsideWhereUniqueInput = { id?: string | null company_reference?: ReferenceCompoundUniqueInput | null }
This looks much better now:
export type CompanyReferenceCompoundUniqueInput = {
company: string
reference: string
}
export type SubsideWhereUniqueInput = {
id?: string | null
company_reference?: CompanyReferenceCompoundUniqueInput | null
}
Example with
@id:schema.prisma
model Company { id String @default(uuid()) @id name String } model CompanyData { id Company @relation(references: [id]) @id someData String }Generated code doesn't contain any
findOne,update, ... Only operations on many objects are generated.
Similar here:

(Tested with [email protected])
Can you please confirm that I did not misunderstand and this also works for you @julien1619?
It's perfect, thank you!