-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite Primary Key with relationMode Prisma and Foreign Key #1387
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
kind/bug
A reported bug.
topic: referentialIntegrity/relationMode
Comments
Druue
added
kind/bug
A reported bug.
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
labels
Mar 15, 2023
Druue
added a commit
to Druue/prisma-debug
that referenced
this issue
Mar 15, 2023
My bad, @Druue . I deleted some data to make it readable but left some garbage. You can remove the generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
model Restaurant {
id BigInt @id @default(autoincrement())
RestaurantPageImages RestaurantPageImages[]
}
model RestaurantPageImages {
restaurantId BigInt
imageId Int
url String
Restaurant Restaurant @relation(fields: [restaurantId], references: [id])
@@id([restaurantId, imageId])
} |
janpio
added
bug/2-confirmed
Bug has been reproduced and confirmed.
and removed
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
labels
Mar 16, 2023
I also have this issue with this schema generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
model User {
id String @id @default(uuid())
name String
image String
createdAt DateTime @default(now())
ownedLobbies Lobby[]
playerships Playership[]
decks Deck[]
}
model Playership {
lobbyId String
userId String
lobby Lobby @relation(fields: [lobbyId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
joinedAt DateTime @default(now())
permissions Int
@@id([lobbyId, userId])
}
model Deck {
name String
createdAt DateTime @default(now())
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
@@id([ownerId, name])
}
model Lobby {
id String @id
createdAt DateTime @default(now())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
playerships Playership[]
@@index([ownerId])
} |
yubrot
added a commit
to yubrot/prisma-engines
that referenced
this issue
Oct 23, 2023
Druue
pushed a commit
to prisma/prisma-engines
that referenced
this issue
Mar 19, 2024
* Fix `relation_fields` validation to accept primary key indexes This resolves prisma/language-tools#1387 --------- Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
kind/bug
A reported bug.
topic: referentialIntegrity/relationMode
Bug description
I have a table with a composite primary key, and one of these keys is also a foreign key:
Yet, I still got the warning on the line
Restaurant Restaurant @relation(fields: [restaurantId], references: [id])
:However, this is misleading because we would not have performance issues since the
restaurantId
is used as a hash key on the composite keyHow to reproduce
Expected behavior
No warning is shown
Prisma information
Prisma 4.9.0
Environment & setup
1.76.0
v4.11.0
The text was updated successfully, but these errors were encountered: