Skip to content

Commit d684c19

Browse files
authored
fix: fix MySQL and stripped_partial_indexes test issues (#5793)
Fixes: - outdated snapshots missing `stripped_partial_indexes` - missing `mariadb-mysql.js.wasm` for some MySQL tests that caused them not to be run - corrects some mysql tests to account for minor change in float precision behavior (see prisma/prisma#29285) /test-all <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Expanded query engine testing to support MariaDB MySQL WASM target compatibility alongside MySQL 8 configurations. * Refactored test validation methodology to use programmatic assertions for improved reliability. * Updated schema describer test expectations to reflect current field handling for index structures. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 0f1690a commit d684c19

4 files changed

Lines changed: 35 additions & 15 deletions

File tree

query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/native/mysql.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use indoc::indoc;
22
use query_engine_tests::*;
33

4-
#[test_suite(only(Mysql("8")))]
4+
#[test_suite(only(Mysql("8", "mariadb-mysql.js.wasm")))]
55
mod datetime {
66
fn schema_date() -> String {
77
let schema = indoc! {
@@ -11,7 +11,7 @@ mod datetime {
1111
childId Int? @unique
1212
child Child? @relation(fields: [childId], references: [id])
1313
}
14-
14+
1515
model Child {
1616
#id(id, Int, @id)
1717
date DateTime @test.Date
@@ -70,7 +70,7 @@ mod datetime {
7070
}
7171
}
7272

73-
#[test_suite(only(Mysql("8")))]
73+
#[test_suite(only(Mysql("8", "mariadb-mysql.js.wasm")))]
7474
mod mysql_decimal {
7575
fn schema_decimal() -> String {
7676
let schema = indoc! {
@@ -113,10 +113,20 @@ mod mysql_decimal {
113113
)
114114
.await?;
115115

116-
insta::assert_snapshot!(
117-
run_query!(&runner, r#"{ findManyParent { id child { float dfloat decFloat } } }"#),
118-
@r###"{"data":{"findManyParent":[{"id":1,"child":{"float":1.1,"dfloat":2.2,"decFloat":"3.1"}}]}}"###
119-
);
116+
let res = runner
117+
.query(r#"{ findManyParent { id child { float dfloat decFloat } } }"#)
118+
.await?
119+
.into_data();
120+
121+
let row = &res.first().expect("should have one result")["findManyParent"]
122+
.as_array()
123+
.expect("should be an array")
124+
.first()
125+
.expect("should have one result")["child"];
126+
127+
assert_eq!(row["float"].as_f64().unwrap() as f32, 1.1);
128+
assert_eq!(row["dfloat"].as_f64().unwrap(), 2.2);
129+
assert_eq!(row["decFloat"].as_str().unwrap(), "3.1");
120130

121131
Ok(())
122132
}
@@ -130,7 +140,7 @@ mod mysql_decimal {
130140
}
131141
}
132142

133-
#[test_suite(only(Mysql("8")))]
143+
#[test_suite(only(Mysql("8", "mariadb-mysql.js.wasm")))]
134144
mod mysql_string {
135145
fn schema_string() -> String {
136146
let schema = indoc! {
@@ -205,7 +215,7 @@ mod mysql_string {
205215
}
206216
}
207217

208-
#[test_suite(only(MySql("8")))]
218+
#[test_suite(only(MySql("8", "mariadb-mysql.js.wasm")))]
209219
mod mysql_bytes {
210220
fn schema_bytes() -> String {
211221
let schema = indoc! {

query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/data_types/native_types/mysql.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ mod mysql {
177177
//"MySQL native decimal types" should "work"
178178
#[connector_test(schema(schema_decimal))]
179179
async fn native_decimal_type(runner: Runner) -> TestResult<()> {
180-
insta::assert_snapshot!(
181-
run_query!(&runner, r#"mutation {
180+
let res = runner
181+
.query(
182+
r#"mutation {
182183
createOneModel(
183184
data: {
184185
float: 1.1
@@ -190,10 +191,16 @@ mod mysql {
190191
dfloat
191192
decFloat
192193
}
193-
}"#),
194-
// decFloat is cut due to precision
195-
@r###"{"data":{"createOneModel":{"float":1.1,"dfloat":2.2,"decFloat":"3.1"}}}"###
196-
);
194+
}"#,
195+
)
196+
.await?
197+
.into_data();
198+
199+
let row = &res.first().expect("should have one result")["createOneModel"];
200+
201+
assert_eq!(row["float"].as_f64().unwrap() as f32, 1.1);
202+
assert_eq!(row["dfloat"].as_f64().unwrap(), 2.2);
203+
assert_eq!(row["decFloat"].as_str().unwrap(), "3.1");
197204

198205
Ok(())
199206
}

schema-engine/sql-schema-describer/tests/describers/mysql_describer_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ fn all_mysql_column_types_must_work(api: TestApi) {
853853
predicate: None,
854854
},
855855
],
856+
stripped_partial_indexes: <StrippedPartialIndexes>,
856857
index_columns: [
857858
IndexColumn {
858859
index_id: IndexId(
@@ -1681,6 +1682,7 @@ fn all_mariadb_column_types_must_work(api: TestApi) {
16811682
predicate: None,
16821683
},
16831684
],
1685+
stripped_partial_indexes: <StrippedPartialIndexes>,
16841686
index_columns: [
16851687
IndexColumn {
16861688
index_id: IndexId(

schema-engine/sql-schema-describer/tests/describers/postgres_describer_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,6 +2893,7 @@ fn multiple_schemas_are_described(api: TestApi) {
28932893
predicate: None,
28942894
},
28952895
],
2896+
stripped_partial_indexes: <StrippedPartialIndexes>,
28962897
index_columns: [
28972898
IndexColumn {
28982899
index_id: IndexId(

0 commit comments

Comments
 (0)