Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(query-engine): fix some PlanetScale tests #4909

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}"#),
Expand All @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why though?

Copy link
Contributor Author

@jkomyno jkomyno Jun 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because foreign keys are disabled by default on PlanetScale. Plus, our PlanetScale simulator lacks the ability to turn foreign key violations on

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add this to the comment?
Also, shouldn't we have an emulated error in this case?

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!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down Expand Up @@ -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?;
Expand Down Expand Up @@ -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);
}

Expand Down
Loading