diff --git a/crates/dbx-core/src/database_export.rs b/crates/dbx-core/src/database_export.rs index 509a16f81..f78a434c0 100644 --- a/crates/dbx-core/src/database_export.rs +++ b/crates/dbx-core/src/database_export.rs @@ -839,7 +839,7 @@ mod tests { assert_eq!( statements, - vec!["INSERT INTO `flags` (`enabled`, `mask`, `label`) VALUES (b'1', b'1010', '1010'), (0, 3, 'off');"] + vec!["INSERT INTO `flags` (`enabled`, `mask`, `label`) VALUES (b'1', b'1010', '1010'), (b'0', 3, 'off');"] ); } diff --git a/crates/dbx-core/src/transfer.rs b/crates/dbx-core/src/transfer.rs index 30ed7f674..da0af58d4 100644 --- a/crates/dbx-core/src/transfer.rs +++ b/crates/dbx-core/src/transfer.rs @@ -478,24 +478,25 @@ pub fn escape_value_typed(val: &serde_json::Value, db_type: &DatabaseType, colum } } }, - serde_json::Value::Number(n) => { - if column_type.is_some_and(is_mysql_bit_type) { - format!("b'{}'", n.to_string()) - } else { - n.to_string() + serde_json::Value::Number(n) => match db_type { + DatabaseType::Mysql | DatabaseType::Doris | DatabaseType::StarRocks => { + if column_type.is_some_and(is_mysql_bit_type) { + format!("b'{}'", n.to_string()) + } else { + n.to_string() + } } - } + _ => n.to_string(), + }, serde_json::Value::String(s) => { - if column_type.is_some_and(is_mysql_bit_type) { - format!( - "b'{}'", - format_literal_string(s, db_type, column_type).replace('\\', "\\\\").replace('\'', "''") - ) - } else { - format!( - "'{}'", - format_literal_string(s, db_type, column_type).replace('\\', "\\\\").replace('\'', "''") - ) + let escaped = format_literal_string(s, db_type, column_type).replace('\\', "\\\\").replace('\'', "''"); + match db_type { + DatabaseType::Mysql | DatabaseType::Doris | DatabaseType::StarRocks + if column_type.is_some_and(is_mysql_bit_type) => + { + format!("b'{escaped}'") + } + _ => format!("'{escaped}'"), } } serde_json::Value::Array(arr) => match db_type {