Skip to content

Commit

Permalink
fix(test): fix mismatched type error in MySQL type tests (#1517)
Browse files Browse the repository at this point in the history
* fix new warning about trailing semicolon in expression macros

* fix(test): fix mismatched type error in MySQL type tests
  • Loading branch information
abonander committed Oct 26, 2021
1 parent 466d3f3 commit d25ab07
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sqlx-macros/src/derives/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ macro_rules! assert_attribute {

macro_rules! fail {
($t:expr, $m:expr) => {
return Err(syn::Error::new_spanned($t, $m));
return Err(syn::Error::new_spanned($t, $m))
};
}

Expand Down
3 changes: 2 additions & 1 deletion sqlx-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ macro_rules! __test_prepared_type {
#[macro_export]
macro_rules! MySql_query_for_test_prepared_type {
() => {
"SELECT {0} <=> ?, {0}, ?"
// MySQL 8.0.27 changed `<=>` to return an unsigned integer
"SELECT CAST({0} <=> ? AS SIGNED INTEGER), {0}, ?"
};
}

Expand Down
6 changes: 4 additions & 2 deletions tests/mysql/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ mod json_tests {

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

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

Expand Down

0 comments on commit d25ab07

Please sign in to comment.