Skip to content

Commit

Permalink
fix(validation): Reword validation msg (prisma#4873)
Browse files Browse the repository at this point in the history
  • Loading branch information
janpio authored May 16, 2024
1 parent 89e2d89 commit 2a74da1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion prisma-fmt/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod tests {
});

let expected = expect![[
r#"{"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError parsing attribute \"@relation\": The relation field `a` on Model `B` is required. This is no longer valid because it's not possible to enforce this constraint on the database level. Please change the field type from `A` to `A?` to fix this.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mb.prisma:4\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 3 | \u001b[0m id String @id\n\u001b[1;94m 4 | \u001b[0m \u001b[1;91ma A\u001b[0m\n\u001b[1;94m 5 | \u001b[0m }\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 1"}"#
r#"{"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError parsing attribute \"@relation\": The relation field `a` on Model `B` is required. This is not valid because it's not possible to enforce this constraint on the database level. Please change the field type from `A` to `A?` to fix this.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mb.prisma:4\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 3 | \u001b[0m id String @id\n\u001b[1;94m 4 | \u001b[0m \u001b[1;91ma A\u001b[0m\n\u001b[1;94m 5 | \u001b[0m }\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 1"}"#
]];

let response = validate(&request.to_string()).unwrap_err();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) fn back_relation_arity_is_optional(relation: InlineRelationWalker<'_>

if back.ast_field().arity.is_required() {
let message = format!(
"The relation field `{}` on Model `{}` is required. This is no longer valid because it's not possible to enforce this constraint on the database level. Please change the field type from `{}` to `{}?` to fix this.",
"The relation field `{}` on Model `{}` is required. This is not valid because it's not possible to enforce this constraint on the database level. Please change the field type from `{}` to `{}?` to fix this.",
back.name(), back.model().name(), forward.model().name(), forward.model().name(),
);

Expand Down
4 changes: 2 additions & 2 deletions psl/psl/tests/attributes/relations/relations_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn required_relation_field_must_error_if_it_is_virtual() {
"#;

let expect = expect![[r#"
[1;91merror[0m: [1mError parsing attribute "@relation": The relation field `address` on Model `User` is required. This is no longer valid because it's not possible to enforce this constraint on the database level. Please change the field type from `Address` to `Address?` to fix this.[0m
[1;91merror[0m: [1mError parsing attribute "@relation": The relation field `address` on Model `User` is required. This is not valid because it's not possible to enforce this constraint on the database level. Please change the field type from `Address` to `Address?` to fix this.[0m
--> schema.prisma:4
 | 
 3 |  id Int @id
Expand Down Expand Up @@ -747,7 +747,7 @@ fn must_error_for_required_one_to_one_self_relations() {
"#;

let expect = expect![[r#"
[1;91merror[0m: [1mError parsing attribute "@relation": The relation field `friendOf` on Model `User` is required. This is no longer valid because it's not possible to enforce this constraint on the database level. Please change the field type from `User` to `User?` to fix this.[0m
[1;91merror[0m: [1mError parsing attribute "@relation": The relation field `friendOf` on Model `User` is required. This is not valid because it's not possible to enforce this constraint on the database level. Please change the field type from `User` to `User?` to fix this.[0m
--> schema.prisma:6
 | 
 5 |  friend User @relation("Friends", fields: friendId, references: id)
Expand Down

0 comments on commit 2a74da1

Please sign in to comment.