-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(psl): retrieve all referential actions based on relationMode (#4844)
* rename referential_actions to reflect that it only works for foreign_keys * add new referential_actions fn that matches on relation_mode and defers to the FK / emulated actions * Add test cases for completions on mongodb and for mysql w/ RM = prisma & FK
- Loading branch information
Showing
18 changed files
with
157 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...text_document_completion/scenarios/referential_actions_relation_mode_fk_mysql/result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"isIncomplete": false, | ||
"items": [ | ||
{ | ||
"label": "Cascade", | ||
"kind": 13, | ||
"detail": "Delete the child records when the parent record is deleted." | ||
}, | ||
{ | ||
"label": "Restrict", | ||
"kind": 13, | ||
"detail": "Prevent deleting a parent record as long as it is referenced." | ||
}, | ||
{ | ||
"label": "NoAction", | ||
"kind": 13, | ||
"detail": "Prevent deleting a parent record as long as it is referenced." | ||
}, | ||
{ | ||
"label": "SetNull", | ||
"kind": 13, | ||
"detail": "Set the referencing fields to NULL when the referenced record is deleted." | ||
}, | ||
{ | ||
"label": "SetDefault", | ||
"kind": 13, | ||
"detail": "Set the referencing field's value to the default when the referenced record is deleted." | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
...xt_document_completion/scenarios/referential_actions_relation_mode_fk_mysql/schema.prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
datasource db { | ||
provider = "mysql" | ||
url = env("DATABASE_URL") | ||
relationMode = "foreignKeys" | ||
} | ||
|
||
model Post { | ||
id Int @id @default(autoincrement()) | ||
title String | ||
author User @relation(fields: [authorId], references: [id], onDelete: <|>) | ||
authorId Int | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
posts Post[] | ||
} |
25 changes: 25 additions & 0 deletions
25
...ocument_completion/scenarios/referential_actions_relation_mode_prisma_mongodb/result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"isIncomplete": false, | ||
"items": [ | ||
{ | ||
"label": "Cascade", | ||
"kind": 13, | ||
"detail": "Delete the child records when the parent record is deleted." | ||
}, | ||
{ | ||
"label": "Restrict", | ||
"kind": 13, | ||
"detail": "Prevent deleting a parent record as long as it is referenced." | ||
}, | ||
{ | ||
"label": "NoAction", | ||
"kind": 13, | ||
"detail": "Prevent deleting a parent record as long as it is referenced." | ||
}, | ||
{ | ||
"label": "SetNull", | ||
"kind": 13, | ||
"detail": "Set the referencing fields to NULL when the referenced record is deleted." | ||
} | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
...ument_completion/scenarios/referential_actions_relation_mode_prisma_mongodb/schema.prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
datasource db { | ||
provider = "mongodb" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model Post { | ||
id String @id @default(auto()) @map("_id") @db.ObjectId | ||
title String | ||
author User @relation(fields: [authorId], references: [id], onDelete: <|>) | ||
authorId String @db.ObjectId | ||
} | ||
|
||
model User { | ||
id String @id @default(auto()) @map("_id") @db.ObjectId | ||
posts Post[] | ||
} |
25 changes: 25 additions & 0 deletions
25
..._document_completion/scenarios/referential_actions_relation_mode_prisma_mysql/result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"isIncomplete": false, | ||
"items": [ | ||
{ | ||
"label": "Cascade", | ||
"kind": 13, | ||
"detail": "Delete the child records when the parent record is deleted." | ||
}, | ||
{ | ||
"label": "Restrict", | ||
"kind": 13, | ||
"detail": "Prevent deleting a parent record as long as it is referenced." | ||
}, | ||
{ | ||
"label": "NoAction", | ||
"kind": 13, | ||
"detail": "Prevent deleting a parent record as long as it is referenced." | ||
}, | ||
{ | ||
"label": "SetNull", | ||
"kind": 13, | ||
"detail": "Set the referencing fields to NULL when the referenced record is deleted." | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
...ocument_completion/scenarios/referential_actions_relation_mode_prisma_mysql/schema.prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
datasource db { | ||
provider = "mysql" | ||
url = env("DATABASE_URL") | ||
relationMode = "prisma" | ||
} | ||
|
||
model Post { | ||
id Int @id @default(autoincrement()) | ||
title String | ||
author User @relation(fields: [authorId], references: [id], onDelete: <|>) | ||
authorId Int | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
posts Post[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters