From 2a74da1ba346c169f86c7fa6614128f697a8ce14 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Thu, 16 May 2024 21:20:31 +0200 Subject: [PATCH] fix(validation): Reword validation msg (#4873) --- prisma-fmt/src/validate.rs | 2 +- .../validation_pipeline/validations/relations/one_to_one.rs | 2 +- psl/psl/tests/attributes/relations/relations_new.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prisma-fmt/src/validate.rs b/prisma-fmt/src/validate.rs index 7bbce19e425d..37f0b034ad30 100644 --- a/prisma-fmt/src/validate.rs +++ b/prisma-fmt/src/validate.rs @@ -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(); diff --git a/psl/psl-core/src/validate/validation_pipeline/validations/relations/one_to_one.rs b/psl/psl-core/src/validate/validation_pipeline/validations/relations/one_to_one.rs index 13852b90e70d..2e5b3f5de1cf 100644 --- a/psl/psl-core/src/validate/validation_pipeline/validations/relations/one_to_one.rs +++ b/psl/psl-core/src/validate/validation_pipeline/validations/relations/one_to_one.rs @@ -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(), ); diff --git a/psl/psl/tests/attributes/relations/relations_new.rs b/psl/psl/tests/attributes/relations/relations_new.rs index 724a499c39e6..38387a2e0c1d 100644 --- a/psl/psl/tests/attributes/relations/relations_new.rs +++ b/psl/psl/tests/attributes/relations/relations_new.rs @@ -232,7 +232,7 @@ fn required_relation_field_must_error_if_it_is_virtual() { "#; let expect = expect![[r#" - error: Error 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. + error: Error 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. --> schema.prisma:4  |   3 |  id Int @id @@ -747,7 +747,7 @@ fn must_error_for_required_one_to_one_self_relations() { "#; let expect = expect![[r#" - error: Error 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. + error: Error 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. --> schema.prisma:6  |   5 |  friend User @relation("Friends", fields: friendId, references: id)