prisma-dbml-generator
prisma-dbml-generator copied to clipboard
TypeError: Cannot read properties of undefined (reading 'type')
Hey, there is some niche error for complex models (many to many)
TypeError: Cannot read properties of undefined (reading 'type')
at getJoinIdType (/prisma-dbml-generator/dist/generator/many-to-many-tables.js:46:28)
at joinField (/prisma-dbml-generator/dist/generator/many-to-many-tables.js:39:47)
I did hack around and that's because of multiple named relations that are completely valid within Prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator dbml {
provider = "node ./dist/generator.js"
mapToDbSchema = "false"
}
model Person {
id String @id @default(uuid())
// this is the problematic definition
SportClubMembers SportClubMembers[] @relation("member")
ScienceClubMembers ScienceClubMembers[] @relation("member")
}
model SportClub {
id String @id @default(uuid())
members SportClubMembers[]
@@unique(id)
}
model ScienceClub {
id String @id @default(uuid())
members ScienceClubMembers[]
@@unique(id)
}
//
// Relations
//
// Members on Somethings
model SportClubMembers {
SportClub SportClub @relation(fields: [sportClubId], references: id)
sportClubId String
Person Person @relation("member", fields: [personId], references: id)
personId String
@@id([sportClubId, personId])
}
model ScienceClubMembers {
ScienceClub ScienceClub @relation(fields: [scienceClubId], references: id)
scienceClubId String
Person Person @relation("member", fields: [personId], references: id)
personId String
@@id([scienceClubId, personId])
}
@marcjulian Any update on this one? I experience this issue as well, I would really like to use this generator
I've been experiencing this for the past few months as well. I regularly try to update, but keep having to downgrade to 0.10.0. So ... bump.
Let me know if there's anything I can do to help 🙂.
Two years on, the problem still occurs. Randomly, but it happens.
No much activity on this project either, which is a bit worrying but understandable.
> prisma generate --generator=dbml
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error:
Cannot read properties of undefined (reading 'type')
I'm commenting out this generator until this issue is resolved (if ever).
Same issue happens to me as well.