Skip to content

Commit

Permalink
fix(test): fix mismatched type error in MySQL type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Oct 26, 2021
1 parent 87e1d1a commit c65acf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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 UNSIGNED 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 UNSIGNED 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 c65acf8

Please sign in to comment.