Skip to content

Commit

Permalink
Add test for missing index quick fix with multibyte characters comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Druue committed Jun 14, 2024
1 parent 03f1367 commit 51eca85
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
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])
}
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}"
}
]
}
}
}
]
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])
}
1 change: 1 addition & 0 deletions prisma-fmt/tests/code_actions/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ scenarios! {
one_to_one_referencing_side_misses_unique_compound_field_indentation_four_spaces
relation_mode_prisma_missing_index
relation_mode_prisma_missing_index_multifile
relation_mode_prisma_missing_index_multibyte
relation_mode_referential_integrity
relation_mode_mysql_foreign_keys_set_default
relation_mode_mysql_foreign_keys_set_default_multifile
Expand Down

0 comments on commit 51eca85

Please sign in to comment.