Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,24 @@ pub(crate) fn mysql_value_to_string(row: &MySqlRow, index: usize, column_name: &
if let Ok(value) = row.try_get::<Option<i32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i16>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i8>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u16>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u8>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<f64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
Expand All @@ -140,6 +155,18 @@ pub(crate) fn mysql_value_to_string(row: &MySqlRow, index: usize, column_name: &
if let Ok(value) = row.try_get::<Option<Vec<u8>>, _>(index) {
return Ok(value.map(|v| decode_mysql_bytes_as_string(&v)));
}
if let Ok(val_ref) = row.try_get_raw(index) {
use sqlx::ValueRef;
if val_ref.is_null() {
return Ok(None);
}
if let Ok(s) = val_ref.as_str() {
return Ok(Some(s.to_string()));
}
if let Ok(b) = val_ref.as_bytes() {
return Ok(Some(decode_mysql_bytes_as_string(b)));
}
}
Err(mysql_decode_error(context, column_name, Some(index), "unsupported value type"))
}

Expand All @@ -162,9 +189,24 @@ pub(crate) fn mysql_value_to_display_string(
if let Ok(value) = row.try_get::<Option<i32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i16>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i8>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u16>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u8>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<f64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
Expand All @@ -189,6 +231,18 @@ pub(crate) fn mysql_value_to_display_string(
if let Ok(value) = row.try_get::<Option<Vec<u8>>, _>(index) {
return Ok(value.map(|v| format!("0x{}", hex::encode(v))));
}
if let Ok(val_ref) = row.try_get_raw(index) {
use sqlx::ValueRef;
if val_ref.is_null() {
return Ok(None);
}
if let Ok(s) = val_ref.as_str() {
return Ok(Some(s.to_string()));
}
if let Ok(b) = val_ref.as_bytes() {
return Ok(Some(decode_mysql_bytes_as_string(b)));
}
}
Err(mysql_decode_error(context, column_name, Some(index), "unsupported value type"))
}

Expand All @@ -213,15 +267,63 @@ pub(crate) fn sqlite_value_to_string(row: &SqliteRow, index: usize, column_name:
if let Ok(value) = row.try_get::<Option<i64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i16>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<i8>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u16>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<u8>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<f64>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<f32>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<bool>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(index) {
return Ok(value.map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()));
}
if let Ok(value) = row.try_get::<Option<chrono::NaiveDateTime>, _>(index) {
return Ok(value.map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()));
}
if let Ok(value) = row.try_get::<Option<chrono::NaiveDate>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<chrono::NaiveTime>, _>(index) {
return Ok(value.map(|v| v.to_string()));
}
if let Ok(value) = row.try_get::<Option<Vec<u8>>, _>(index) {
return Ok(value.map(|v| format!("0x{}", hex::encode(v))));
}
if let Ok(val_ref) = row.try_get_raw(index) {
use sqlx::ValueRef;
if val_ref.is_null() {
return Ok(None);
}
if let Ok(s) = val_ref.as_str() {
return Ok(Some(s.to_string()));
}
if let Ok(b) = val_ref.as_bytes() {
return Ok(Some(String::from_utf8_lossy(b).to_string()));
}
}
Err(sqlite_decode_error(context, column_name, Some(index), "unsupported value type"))
}

Expand Down
78 changes: 78 additions & 0 deletions src-tauri/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,30 @@ fn mysql_value_to_string(row: &MySqlRow, index: usize, column_name: &str, contex
if let Ok(value) = row.try_get::<Option<i32>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<i16>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<i8>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u64>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u32>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u16>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u8>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<f64>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<f32>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<bool>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
Expand All @@ -633,6 +651,18 @@ fn mysql_value_to_string(row: &MySqlRow, index: usize, column_name: &str, contex
.map(|v| format!("0x{}", hex::encode(v)))
.unwrap_or_default());
}
if let Ok(val_ref) = row.try_get_raw(index) {
use sqlx::ValueRef;
if val_ref.is_null() {
return Ok(String::new());
}
if let Ok(s) = val_ref.as_str() {
return Ok(s.to_string());
}
if let Ok(b) = val_ref.as_bytes() {
return Ok(String::from_utf8_lossy(b).to_string());
}
}
Err(format!(
"MySQL decode error in {} at column '{}' (index {}): unsupported value type",
context, column_name, index
Expand All @@ -646,17 +676,65 @@ fn sqlite_value_to_string(row: &SqliteRow, index: usize, column_name: &str, cont
if let Ok(value) = row.try_get::<Option<i64>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<i32>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<i16>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<i8>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u64>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u32>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u16>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<u8>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<f64>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<f32>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<bool>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(index) {
return Ok(value.map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<chrono::NaiveDateTime>, _>(index) {
return Ok(value.map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<chrono::NaiveDate>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<chrono::NaiveTime>, _>(index) {
return Ok(value.map(|v| v.to_string()).unwrap_or_default());
}
if let Ok(value) = row.try_get::<Option<Vec<u8>>, _>(index) {
return Ok(value
.map(|v| format!("0x{}", hex::encode(v)))
.unwrap_or_default());
}
if let Ok(val_ref) = row.try_get_raw(index) {
use sqlx::ValueRef;
if val_ref.is_null() {
return Ok(String::new());
}
if let Ok(s) = val_ref.as_str() {
return Ok(s.to_string());
}
if let Ok(b) = val_ref.as_bytes() {
return Ok(String::from_utf8_lossy(b).to_string());
}
}
Err(format!(
"SQLite decode error in {} at column '{}' (index {}): unsupported value type",
context, column_name, index
Expand Down