From 3c08e980af67c76cf4795659b0be64c0905af5e2 Mon Sep 17 00:00:00 2001 From: zjregee Date: Sun, 1 Sep 2024 17:07:52 +0800 Subject: [PATCH] alignment logic Signed-off-by: zjregee --- sqllogictest-engines/src/mysql.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sqllogictest-engines/src/mysql.rs b/sqllogictest-engines/src/mysql.rs index 15d74e7..ae43411 100644 --- a/sqllogictest-engines/src/mysql.rs +++ b/sqllogictest-engines/src/mysql.rs @@ -2,7 +2,9 @@ use std::process::Command; use std::time::Duration; use async_trait::async_trait; -use mysql_async::prelude::*; +use mysql_async::prelude::FromValue; +use mysql_async::prelude::Queryable; +use mysql_async::FromValueError; use sqllogictest::{DBOutput, DefaultColumnType}; type Result = std::result::Result; @@ -36,8 +38,20 @@ impl sqllogictest::AsyncDB for MySql { for row in rows { let mut row_vec = vec![]; for i in 0..row.len() { - let value: String = FromValue::from_value(row[i].clone()); - row_vec.push(value); + let value: std::result::Result = + FromValue::from_value_opt(row[i].clone()); + match value { + Ok(value) => { + if value.is_empty() { + row_vec.push("(empty)".to_string()); + } else { + row_vec.push(value); + } + } + Err(_) => { + row_vec.push("NULL".to_string()); + } + } } output.push(row_vec); }