Skip to content

Commit 4f5d3a4

Browse files
committed
Fix UUID test for various databases
1 parent dc88ab9 commit 4f5d3a4

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

tests/any/any.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,16 @@ async fn it_has_json() -> anyhow::Result<()> {
116116
#[sqlx_macros::test]
117117
async fn it_has_uuid() -> anyhow::Result<()> {
118118
use sqlx_oldapi::types::Uuid;
119-
#[cfg(feature = "sqlite")]
120-
let sql = "x'123e4567e89b12d3a456426614174000'";
121-
#[cfg(feature = "mssql")]
122-
let sql = "CONVERT(uniqueidentifier, '123e4567-e89b-12d3-a456-426614174000')";
123-
#[cfg(feature = "postgres")]
124-
let sql = "CAST('123e4567-e89b-12d3-a456-426614174000' AS UUID)";
125-
#[cfg(feature = "mysql")]
126-
let sql = "UUID_TO_BIN('123e4567-e89b-12d3-a456-426614174000')";
127119
assert_eq!(
128120
Uuid::parse_str("123e4567-e89b-12d3-a456-426614174000")?,
129-
get_val::<Uuid>(sql).await?
121+
get_val::<Uuid>(if cfg!(feature = "mssql") {
122+
"CONVERT(uniqueidentifier, '123e4567-e89b-12d3-a456-426614174000')²"
123+
} else if cfg!(feature = "postgres") {
124+
"'123e4567-e89b-12d3-a456-426614174000'::uuid"
125+
} else {
126+
"x'123e4567e89b12d3a456426614174000'"
127+
})
128+
.await?
130129
);
131130
Ok(())
132131
}

0 commit comments

Comments
 (0)