Failed to generate when model without PK
dznbk opened this issue · comments
Describe the bug
プライマリキーを持たないmodelの場合、npx prisma generate実行時に
Cannot read properties of undefined (reading 'name')
が発生し、generateに失敗してしまいます。
To Reproduce
後述するschema.prismaを用意し、npx prisma generateを実行で確認できます。
CompanyEmployeeに、@id、もしくは@@idでPKを設定すれば、発生しないことを確認しています。
Expected behavior
generateの正常終了
Your Schema
// Paste schema.prisma file.
model Company {
id String @id
name String
companyEmployees CompanyEmployee[]
}
model Employee {
id String @id
name String
companyEmployees CompanyEmployee?
}
model CompanyEmployee {
company Company @relation(fields: [companyId], references: [id])
companyId String
employee Employee @relation(fields: [employeeId], references: [id])
employeeId String @unique
@@unique([companyId, employeeId])
}
Environment (please complete the following information):
- Database kind [sqlite]
- Node.js version [18.11.0]
@prisma/client
version [4.6.1]- TypeScript version [4.9.3]
Additional context
93247ec
コードは最新のものから、特に変更を加えず確認しています。
I fixed and published as v0.2.2. Thanks for your reporting!