From 8a7b4f74944cb1cab02159537bb3684f92958cd1 Mon Sep 17 00:00:00 2001 From: jkomyno Date: Thu, 6 Jun 2024 11:38:51 +0200 Subject: [PATCH 1/2] test(query-engine): Fix PlanetScale test, #4482 --- .../compound_fks_mixed_requiredness.rs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/relations/compound_fks_mixed_requiredness.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/relations/compound_fks_mixed_requiredness.rs index d1be84d2d9a9..c0c80a5a8e14 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/relations/compound_fks_mixed_requiredness.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/relations/compound_fks_mixed_requiredness.rs @@ -25,11 +25,11 @@ mod compound_fks { schema.to_owned() } - // "A One to Many relation with mixed requiredness" should "be writable and readable"- - // In PlanetScale, this fails with: - // `Expected result to return an error, but found success: {"data":{"createOnePost":{"id":2,"user_id":2,"user_age":2,"User":null}}}` - #[connector_test(exclude(MySql(5.6), MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))] + // "A One to Many relation with mixed requiredness" should "be writable and readable" + #[connector_test(exclude(MySql(5.6), MongoDb))] async fn one2m_mix_required_writable_readable(runner: Runner) -> TestResult<()> { + use query_tests_setup::{ConnectorVersion, VitessVersion::*}; + // Setup user insta::assert_snapshot!( run_query!(&runner, r#"mutation{createOneUser(data:{id: 1, nr:1, age: 1}){id, nr, age, Post{id}}}"#), @@ -49,12 +49,17 @@ mod compound_fks { @r###"{"data":{"createOnePost":{"id":1,"user_id":1,"user_age":null,"User":null}}}"### ); - // Foreign key violation - assert_error!( - &runner, - r#"mutation{createOnePost(data:{id: 2, user_id:2, user_age: 2}){id, user_id, user_age, User{id}}}"#, - 2003 - ); + // Foreign key violation, which doesn't happen on PlanetScale. + if !matches!( + runner.connector_version(), + ConnectorVersion::Vitess(Some(PlanetscaleJsNapi)) | ConnectorVersion::Vitess(Some(PlanetscaleJsWasm)) + ) { + assert_error!( + &runner, + r#"mutation{createOnePost(data:{id: 2, user_id:2, user_age: 2}){id, user_id, user_age, User{id}}}"#, + 2003 + ); + } // Success insta::assert_snapshot!( From e7ad2425b055475b926b55801c986c3f1ad1050c Mon Sep 17 00:00:00 2001 From: jkomyno Date: Thu, 6 Jun 2024 11:39:44 +0200 Subject: [PATCH 2/2] test(query-engine): Fix PlanetScale test, #4485 --- .../tests/writes/top_level_mutations/update_many.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/update_many.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/update_many.rs index f821bb43dcab..c9a6d6df567c 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/update_many.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/top_level_mutations/update_many.rs @@ -123,7 +123,7 @@ mod update_many { } // "An updateMany mutation" should "correctly apply all number operations for Int" - #[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm"), CockroachDb))] + #[connector_test(exclude(CockroachDb))] async fn apply_number_ops_for_int(runner: Runner) -> TestResult<()> { create_row(&runner, r#"{ id: 1, optStr: "str1" }"#).await?; create_row(&runner, r#"{ id: 2, optStr: "str2", optInt: 2 }"#).await?; @@ -240,7 +240,7 @@ mod update_many { } // "An updateMany mutation" should "correctly apply all number operations for Float" - #[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))] + #[connector_test] async fn apply_number_ops_for_float(runner: Runner) -> TestResult<()> { create_row(&runner, r#"{ id: 1, optStr: "str1" }"#).await?; create_row(&runner, r#"{ id: 2, optStr: "str2", optFloat: 2 }"#).await?; @@ -297,10 +297,10 @@ mod update_many { let count = &res["data"]["updateManyTestModel"]["count"]; // MySql does not count incrementing a null so the count is different - if !matches!(runner.connector_version(), ConnectorVersion::MySql(_)) { - // On PlanetScale, this fails with: - // left: Number(2) - // right: 3 + if !matches!( + runner.connector_version(), + ConnectorVersion::MySql(_) | ConnectorVersion::Vitess(_) + ) { assert_eq!(count, 3); }