-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for missing index quick fix with multibyte characters comment
- Loading branch information
Showing
4 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
13 changes: 7 additions & 6 deletions
13
prisma-fmt/tests/code_actions/scenarios/relation_mode_prisma_missing_index/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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
provider = "prisma-client-js" | ||
previewFeatures = ["referentialIntegrity"] | ||
} | ||
|
||
datasource db { | ||
provider = "mysql" | ||
url = env("TEST_DATABASE_URL") | ||
provider = "mysql" | ||
url = env("TEST_DATABASE_URL") | ||
relationMode = "prisma" | ||
} | ||
|
||
model SomeUser { | ||
id Int @id | ||
id Int @id | ||
posts Post[] | ||
} | ||
|
||
// comment | ||
model Post { | ||
id Int @id | ||
id Int @id | ||
userId Int | ||
user SomeUser @relation(fields: [userId], references: [id]) | ||
user SomeUser @relation(fields: [userId], references: [id]) | ||
} |
41 changes: 41 additions & 0 deletions
41
...fmt/tests/code_actions/scenarios/relation_mode_prisma_missing_index_multibyte/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,41 @@ | ||
[ | ||
{ | ||
"title": "Add an index for the relation's field(s)", | ||
"kind": "quickfix", | ||
"diagnostics": [ | ||
{ | ||
"range": { | ||
"start": { | ||
"line": 19, | ||
"character": 18 | ||
}, | ||
"end": { | ||
"line": 19, | ||
"character": 63 | ||
} | ||
}, | ||
"severity": 2, | ||
"message": "With `relationMode = \"prisma\"`, no foreign keys are used, so relation fields will not benefit from the index usually created by the relational database under the hood. This can lead to poor performance when querying these fields. We recommend adding an index manually. Learn more at https://pris.ly/d/relation-mode-prisma-indexes\" " | ||
} | ||
], | ||
"edit": { | ||
"changes": { | ||
"file:///path/to/schema.prisma": [ | ||
{ | ||
"range": { | ||
"start": { | ||
"line": 20, | ||
"character": 0 | ||
}, | ||
"end": { | ||
"line": 20, | ||
"character": 1 | ||
} | ||
}, | ||
"newText": "\n @@index([userId])\n}" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] |
22 changes: 22 additions & 0 deletions
22
...t/tests/code_actions/scenarios/relation_mode_prisma_missing_index_multibyte/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,22 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["referentialIntegrity"] | ||
} | ||
|
||
datasource db { | ||
provider = "mysql" | ||
url = env("TEST_DATABASE_URL") | ||
relationMode = "prisma" | ||
} | ||
|
||
model SomeUser { | ||
id Int @id | ||
posts Post[] | ||
} | ||
|
||
/// абвгд | ||
model Post { | ||
id Int @id | ||
userId Int | ||
user SomeUser @relation(fields: [userId], references: [id]) | ||
} |
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