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(driver-adapters): fix / uncomment tests #4738

Merged
merged 6 commits into from
Feb 28, 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
1 change: 1 addition & 0 deletions quaint/src/connector/postgres/native/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ impl ToColumnNames for PostgresStatement {
}
}

// TODO: consider porting this logic to Driver Adapters as well
impl<'a> ToSql for Value<'a> {
fn to_sql(
&self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use query_engine_tests::test_suite;
use std::borrow::Cow;

#[test_suite(schema(generic), exclude(Vitess("planetscale.js")))]
#[test_suite(schema(generic))]
mod interactive_tx {
use query_engine_tests::*;
use tokio::time;
Expand Down Expand Up @@ -213,7 +213,7 @@ mod interactive_tx {
Ok(())
}

#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(Vitess("planetscale.js.wasm")))]
async fn batch_queries_failure(mut runner: Runner) -> TestResult<()> {
// Tx expires after five second.
let tx_id = runner.start_tx(5000, 5000, None).await?;
Expand Down Expand Up @@ -256,7 +256,7 @@ mod interactive_tx {
Ok(())
}

#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(Vitess("planetscale.js.wasm")))]
async fn tx_expiration_failure_cycle(mut runner: Runner) -> TestResult<()> {
// Tx expires after one seconds.
let tx_id = runner.start_tx(5000, 1000, None).await?;
Expand Down Expand Up @@ -598,6 +598,8 @@ mod itx_isolation {
Ok(())
}

// On PlanetScale, this fails with:
// `InteractiveTransactionError("Error in connector: Error querying the database: Server error: `ERROR 25001 (1568): Transaction characteristics can't be changed while a transaction is in progress'")`
#[connector_test(exclude(MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))]
async fn casing_doesnt_matter(mut runner: Runner) -> TestResult<()> {
let tx_id = runner.start_tx(5000, 5000, Some("sErIaLiZaBlE".to_owned())).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ mod max_integer {
}

// Info: `driver-adapters` are currently excluded because they yield a different error message,
// coming straight from the database.
// coming straight from the database. This is because these "Unable to fit integer value" errors
// are only thrown by the native quaint driver, not the underlying database driver.
#[connector_test(
schema(overflow_pg),
only(Postgres),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod transactional {
Ok(())
}

#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test]
async fn one_success_one_fail(runner: Runner) -> TestResult<()> {
let queries = vec![
r#"mutation { createOneModelA(data: { id: 1 }) { id }}"#.to_string(),
Expand Down Expand Up @@ -77,7 +77,7 @@ mod transactional {
Ok(())
}

#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test]
async fn one_query(runner: Runner) -> TestResult<()> {
// Existing ModelA in the DB will prevent the nested ModelA creation in the batch.
insta::assert_snapshot!(
Expand All @@ -104,6 +104,8 @@ mod transactional {
Ok(())
}

// On PlanetScale, this fails with:
// "Error in connector: Error querying the database: Server error: `ERROR 25001 (1568): Transaction characteristics can't be changed while a transaction is in progress'""
#[connector_test(exclude(MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))]
async fn valid_isolation_level(runner: Runner) -> TestResult<()> {
let queries = vec![r#"mutation { createOneModelB(data: { id: 1 }) { id }}"#.to_string()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ mod search_filter_with_index {
super::ensure_filter_tree_shake_works(runner).await
}

// This test correctly fails on PlanetScale, but its message is not the same as the one in the test:
// "DatabaseError: Can't find FULLTEXT index matching the column list (errno 1191) (sqlstate HY000)"
#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test]
async fn throws_error_on_missing_index(runner: Runner) -> TestResult<()> {
super::create_test_data(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ mod order_by_dependent {
}

// "[Circular with differing records] Ordering by related record field ascending" should "work"
#[connector_test(exclude(SqlServer, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(SqlServer))]
async fn circular_diff_related_record_asc(runner: Runner) -> TestResult<()> {
// Records form circles with their relations
create_row(&runner, 1, Some(1), Some(1), Some(3)).await?;
Expand All @@ -244,7 +244,10 @@ mod order_by_dependent {
}
}"#,
MongoDb(_) | Sqlite(_) => vec![r#"{"data":{"findManyModelA":[{"id":3,"b":null},{"id":4,"b":null},{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":2,"b":{"c":{"a":{"id":4}}}}]}}"#],
MySql(_) | CockroachDb(_) => vec![
MySql(_)
| CockroachDb(_)
| Vitess(Some(VitessVersion::PlanetscaleJsNapi))
| Vitess(Some(VitessVersion::PlanetscaleJsWasm)) => vec![
r#"{"data":{"findManyModelA":[{"id":4,"b":null},{"id":3,"b":null},{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":2,"b":{"c":{"a":{"id":4}}}}]}}"#,
r#"{"data":{"findManyModelA":[{"id":3,"b":null},{"id":4,"b":null},{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":2,"b":{"c":{"a":{"id":4}}}}]}}"#,
],
Expand All @@ -258,7 +261,7 @@ mod order_by_dependent {
}

// "[Circular with differing records] Ordering by related record field descending" should "work"
#[connector_test(exclude(SqlServer, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(SqlServer))]
async fn circular_diff_related_record_desc(runner: Runner) -> TestResult<()> {
// Records form circles with their relations
create_row(&runner, 1, Some(1), Some(1), Some(3)).await?;
Expand All @@ -279,7 +282,10 @@ mod order_by_dependent {
}
}"#,
MongoDb(_) | Sqlite(_)=> vec![r#"{"data":{"findManyModelA":[{"id":2,"b":{"c":{"a":{"id":4}}}},{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":3,"b":null},{"id":4,"b":null}]}}"#],
MySql(_) | CockroachDb(_) => vec![
MySql(_)
| CockroachDb(_)
| Vitess(Some(VitessVersion::PlanetscaleJsNapi))
| Vitess(Some(VitessVersion::PlanetscaleJsWasm)) => vec![
r#"{"data":{"findManyModelA":[{"id":2,"b":{"c":{"a":{"id":4}}}},{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":4,"b":null},{"id":3,"b":null}]}}"#,
r#"{"data":{"findManyModelA":[{"id":2,"b":{"c":{"a":{"id":4}}}},{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":3,"b":null},{"id":4,"b":null}]}}"#,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod order_by_dependent_pag {

// "[Hops: 1] Ordering by related record field ascending with nulls" should "work"
// TODO(julius): should enable for SQL Server when partial indices are in the PSL
#[connector_test(exclude(SqlServer, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(SqlServer))]
async fn hop_1_related_record_asc_nulls(runner: Runner) -> TestResult<()> {
// 1 record has the "full chain", one half, one none
create_row(&runner, 1, Some(1), Some(1), None).await?;
Expand All @@ -97,7 +97,12 @@ mod order_by_dependent_pag {
}
}"#,
// Depends on how null values are handled.
MongoDb(_) | Sqlite(_) | MySql(_) | CockroachDb(_) => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"id":1}},{"id":2,"b":{"id":2}}]}}"#],
MongoDb(_)
| Sqlite(_)
| MySql(_)
| CockroachDb(_)
| Vitess(Some(VitessVersion::PlanetscaleJsNapi))
| Vitess(Some(VitessVersion::PlanetscaleJsWasm)) => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"id":1}},{"id":2,"b":{"id":2}}]}}"#],
_ => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"id":1}},{"id":2,"b":{"id":2}},{"id":3,"b":null}]}}"#]
);

Expand Down Expand Up @@ -146,7 +151,7 @@ mod order_by_dependent_pag {

// "[Hops: 2] Ordering by related record field ascending with nulls" should "work"
// TODO(garren): should enable for SQL Server when partial indices are in the PSL
#[connector_test(exclude(SqlServer, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(SqlServer))]
async fn hop_2_related_record_asc_null(runner: Runner) -> TestResult<()> {
// 1 record has the "full chain", one half, one none
create_row(&runner, 1, Some(1), Some(1), None).await?;
Expand All @@ -166,7 +171,12 @@ mod order_by_dependent_pag {
}
}"#,
// Depends on how null values are handled.
MongoDb(_) | Sqlite(_) | MySql(_) | CockroachDb(_) => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"c":{"id":1}}}]}}"#],
MongoDb(_)
| Sqlite(_)
| MySql(_)
| CockroachDb(_)
| Vitess(Some(VitessVersion::PlanetscaleJsNapi))
| Vitess(Some(VitessVersion::PlanetscaleJsWasm)) => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"c":{"id":1}}}]}}"#],
_ => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"c":{"id":1}}},{"id":2,"b":{"c":null}},{"id":3,"b":null}]}}"#]
);

Expand Down Expand Up @@ -227,7 +237,7 @@ mod order_by_dependent_pag {

// "[Circular with differing records] Ordering by related record field ascending" should "work"
// TODO(julius): should enable for SQL Server when partial indices are in the PSL
#[connector_test(exclude(SqlServer, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(SqlServer))]
async fn circular_diff_related_record_asc(runner: Runner) -> TestResult<()> {
// Records form circles with their relations
create_row(&runner, 1, Some(1), Some(1), Some(3)).await?;
Expand All @@ -248,7 +258,12 @@ mod order_by_dependent_pag {
}
}"#,
// Depends on how null values are handled.
MongoDb(_) | MySql(_) | Sqlite(_) | CockroachDb(_) => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":2,"b":{"c":{"a":{"id":4}}}}]}}"#],
MongoDb(_)
| Sqlite(_)
| MySql(_)
| CockroachDb(_)
| Vitess(Some(VitessVersion::PlanetscaleJsNapi))
| Vitess(Some(VitessVersion::PlanetscaleJsWasm)) => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":2,"b":{"c":{"a":{"id":4}}}}]}}"#],
_ => vec![r#"{"data":{"findManyModelA":[{"id":1,"b":{"c":{"a":{"id":3}}}},{"id":2,"b":{"c":{"a":{"id":4}}}},{"id":3,"b":null},{"id":4,"b":null}]}}"#]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ mod byoid {
}

// "A Create Mutation" should "create and return item with own Id"
#[connector_test(
schema(schema_1),
only(MySql, Postgres, Sqlite, Vitess),
exclude(Vitess("planetscale.js", "planetscale.js.wasm"))
)]
#[connector_test(schema(schema_1), only(MySql, Postgres, Sqlite, Vitess))]
async fn create_and_return_item_woi_1(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand All @@ -59,7 +55,11 @@ mod byoid {
);

let error_target = match runner.connector_version() {
query_engine_tests::ConnectorVersion::MySql(_) => "constraint: `PRIMARY`",
query_engine_tests::ConnectorVersion::MySql(_)
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsNapi))
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsWasm)) => {
"constraint: `PRIMARY`"
}
query_engine_tests::ConnectorVersion::Vitess(_) => "(not available)",
_ => "fields: (`id`)",
};
Expand All @@ -77,11 +77,7 @@ mod byoid {
}

// "A Create Mutation" should "create and return item with own Id"
#[connector_test(
schema(schema_2),
only(MySql, Postgres, Sqlite, Vitess),
exclude(Vitess("planetscale.js", "planetscale.js.wasm"))
)]
#[connector_test(schema(schema_2), only(MySql, Postgres, Sqlite, Vitess))]
async fn create_and_return_item_woi_2(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand All @@ -91,7 +87,11 @@ mod byoid {
);

let error_target = match runner.connector_version() {
ConnectorVersion::MySql(_) => "constraint: `PRIMARY`",
query_engine_tests::ConnectorVersion::MySql(_)
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsNapi))
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsWasm)) => {
"constraint: `PRIMARY`"
}
ConnectorVersion::Vitess(_) => "(not available)",
_ => "fields: (`id`)",
};
Expand Down Expand Up @@ -139,11 +139,7 @@ mod byoid {
}

// "A Nested Create Mutation" should "create and return item with own Id"
#[connector_test(
schema(schema_1),
only(MySql, Postgres, Sqlite, Vitess),
exclude(Vitess("planetscale.js", "planetscale.js.wasm"))
)]
#[connector_test(schema(schema_1), only(MySql, Postgres, Sqlite, Vitess))]
async fn nested_create_return_item_woi_1(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand All @@ -153,7 +149,11 @@ mod byoid {
);

let error_target = match runner.connector_version() {
ConnectorVersion::MySql(_) => "constraint: `PRIMARY`",
query_engine_tests::ConnectorVersion::MySql(_)
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsNapi))
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsWasm)) => {
"constraint: `PRIMARY`"
}
ConnectorVersion::Vitess(_) => "(not available)",
_ => "fields: (`id`)",
};
Expand All @@ -171,11 +171,7 @@ mod byoid {
}

// "A Nested Create Mutation" should "create and return item with own Id"
#[connector_test(
schema(schema_2),
only(MySql, Postgres, Sqlite, Vitess),
exclude(Vitess("planetscale.js", "planetscale.js.wasm"))
)]
#[connector_test(schema(schema_2), only(MySql, Postgres, Sqlite, Vitess))]
async fn nested_create_return_item_woi_2(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand All @@ -185,7 +181,11 @@ mod byoid {
);

let error_target = match runner.connector_version() {
ConnectorVersion::MySql(_) => "constraint: `PRIMARY`",
query_engine_tests::ConnectorVersion::MySql(_)
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsNapi))
| query_engine_tests::ConnectorVersion::Vitess(Some(query_tests_setup::VitessVersion::PlanetscaleJsWasm)) => {
"constraint: `PRIMARY`"
}
ConnectorVersion::Vitess(_) => "(not available)",
_ => "fields: (`id`)",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mod nested_create_many {

// "Nested createMany" should "error on duplicates by default"
// TODO(dom): Not working for mongo
#[connector_test(exclude(Sqlite, MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(Sqlite, MongoDb))]
async fn nested_createmany_fail_dups(runner: Runner) -> TestResult<()> {
assert_error!(
&runner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ mod compound_fks {
schema.to_owned()
}

// "A One to Many relation with mixed requiredness" should "be writable and readable"
// "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")))]
async fn one2m_mix_required_writable_readable(runner: Runner) -> TestResult<()> {
// Setup user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ mod create {
// TODO(dom): Not working on mongo
// TODO(dom): 'Expected result to return an error, but found success: {"data":{"createOneScalarModel":{"optUnique":"test"}}}'
// Comment(dom): Expected, we're not enforcing uniqueness for the test setup yet.
#[connector_test(exclude(MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(exclude(MongoDb))]
async fn gracefully_fails_when_uniq_violation(runner: Runner) -> TestResult<()> {
run_query!(
&runner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ mod create_many {
}

// "createMany" should "error on duplicates by default"
#[connector_test(schema(schema_4), exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(schema(schema_4))]
async fn create_many_error_dups(runner: Runner) -> TestResult<()> {
assert_error!(
&runner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ mod update_many {

// 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
assert_eq!(count, 3);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ mod upsert {
Ok(())
}

#[connector_test(schema(generic), exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test(schema(generic))]
async fn upsert_fails_if_filter_dont_match(runner: Runner) -> TestResult<()> {
run_query!(
&runner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod sqlite;
mod vitess;

pub use mysql::MySqlVersion;
pub use vitess::VitessVersion;

pub(crate) use cockroachdb::*;
pub(crate) use js::*;
Expand Down
Loading