Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
psl: fix newline boundary search in relation reformatting
When adding an @relation attribute to a forward relation field in the relation reformatting code that deals with adding missing relation fields and attributes, we searched for the last character before a newline to check whether it is a carriage return, but we failed to check whether the byte offset was a char boundary first. This caused crashes. closes prisma/prisma#14895
- Loading branch information
Showing
4 changed files
with
53 additions
and
0 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
23 changes: 23 additions & 0 deletions
23
psl/psl/tests/reformatter/regression_thai_trailing_comments.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,23 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
output = "./generated/client" | ||
} | ||
|
||
datasource db { | ||
provider = "sqlserver" | ||
url = "***" | ||
} | ||
|
||
model somemodel { | ||
frownyFaceId String | ||
frownyFace frownyface // 囧 | ||
id Int @id | ||
} | ||
|
||
model frownyface { | ||
somes somemodel[] | ||
} |
23 changes: 23 additions & 0 deletions
23
psl/psl/tests/reformatter/regression_thai_trailing_comments.reformatted.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,23 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
output = "./generated/client" | ||
} | ||
|
||
datasource db { | ||
provider = "sqlserver" | ||
url = "***" | ||
} | ||
|
||
model somemodel { | ||
frownyFaceId String | ||
frownyFace frownyface // 囧 @relation(fields: [], references: []) | ||
id Int @id | ||
} | ||
|
||
model frownyface { | ||
somes somemodel[] | ||
} |