Skip to content

Commit d25ab07

Browse files
authored
fix(test): fix mismatched type error in MySQL type tests (#1517)
* fix new warning about trailing semicolon in expression macros * fix(test): fix mismatched type error in MySQL type tests
1 parent 466d3f3 commit d25ab07

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

sqlx-macros/src/derives/attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ macro_rules! assert_attribute {
1515

1616
macro_rules! fail {
1717
($t:expr, $m:expr) => {
18-
return Err(syn::Error::new_spanned($t, $m));
18+
return Err(syn::Error::new_spanned($t, $m))
1919
};
2020
}
2121

sqlx-test/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ macro_rules! __test_prepared_type {
197197
#[macro_export]
198198
macro_rules! MySql_query_for_test_prepared_type {
199199
() => {
200-
"SELECT {0} <=> ?, {0}, ?"
200+
// MySQL 8.0.27 changed `<=>` to return an unsigned integer
201+
"SELECT CAST({0} <=> ? AS SIGNED INTEGER), {0}, ?"
201202
};
202203
}
203204

tests/mysql/types.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ mod json_tests {
235235

236236
test_type!(json<JsonValue>(
237237
MySql,
238-
"SELECT CAST({0} AS BINARY) <=> CAST(? AS BINARY), CAST({0} AS BINARY) as _2, ? as _3",
238+
// MySQL 8.0.27 changed `<=>` to return an unsigned integer
239+
"SELECT CAST(CAST({0} AS BINARY) <=> CAST(? AS BINARY) AS SIGNED INTEGER), CAST({0} AS BINARY) as _2, ? as _3",
239240
"'\"Hello, World\"'" == json!("Hello, World"),
240241
"'\"😎\"'" == json!("😎"),
241242
"'\"🙋‍♀️\"'" == json!("🙋‍♀️"),
@@ -250,7 +251,8 @@ mod json_tests {
250251

251252
test_type!(json_struct<Json<Friend>>(
252253
MySql,
253-
"SELECT CAST({0} AS BINARY) <=> CAST(? AS BINARY), CAST({0} AS BINARY) as _2, ? as _3",
254+
// MySQL 8.0.27 changed `<=>` to return an unsigned integer
255+
"SELECT CAST(CAST({0} AS BINARY) <=> CAST(? AS BINARY) AS SIGNED INTEGER), CAST({0} AS BINARY) as _2, ? as _3",
254256
"\'{\"name\":\"Joe\",\"age\":33}\'" == Json(Friend { name: "Joe".to_string(), age: 33 })
255257
));
256258

0 commit comments

Comments
 (0)