Skip to content

Commit 22c8728

Browse files
committed
test(odbc): add UTF-8 binary data handling test
This commit introduces a new test to verify the handling of text data as UTF-8 binary in ODBC connections. The test ensures that UTF-8 encoded strings are correctly processed and retrieved as byte arrays, enhancing the robustness of binary data handling in the ODBC module.
1 parent b2c7ef3 commit 22c8728

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/odbc/odbc.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,25 @@ async fn it_handles_binary_data() -> anyhow::Result<()> {
454454
Ok(())
455455
}
456456

457+
#[tokio::test]
458+
async fn it_handles_text_as_utf8_binary() -> anyhow::Result<()> {
459+
let mut conn = new::<Odbc>().await?;
460+
461+
// Test binary data - use UTF-8 safe bytes for PostgreSQL compatibility
462+
let text = "Héllö world! 😀";
463+
let stmt = conn.prepare("SELECT ? AS text_data").await?;
464+
let row = stmt
465+
.query_as::<(Vec<u8>,)>()
466+
.bind(text)
467+
.fetch_optional(&mut conn)
468+
.await
469+
.expect("query failed")
470+
.expect("row expected");
471+
472+
assert_eq!(row.0, text.as_bytes());
473+
Ok(())
474+
}
475+
457476
#[tokio::test]
458477
async fn it_handles_mixed_null_and_values() -> anyhow::Result<()> {
459478
let mut conn = new::<Odbc>().await?;

0 commit comments

Comments
 (0)