diff --git a/plugins/sql/Cargo.toml b/plugins/sql/Cargo.toml index e1a5feefcf..e39ba0af3c 100644 --- a/plugins/sql/Cargo.toml +++ b/plugins/sql/Cargo.toml @@ -29,7 +29,7 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } futures-core = "0.3" -sqlx = { version = "0.8", features = ["json", "time", "uuid"] } +sqlx = { version = "0.8", features = ["json", "time", "uuid", "bigdecimal"] } time = "0.3" tokio = { version = "1", features = ["sync"] } indexmap = { version = "2", features = ["serde"] } diff --git a/plugins/sql/src/decode/mysql.rs b/plugins/sql/src/decode/mysql.rs index 53fd20c7c4..4e1f6c45cf 100644 --- a/plugins/sql/src/decode/mysql.rs +++ b/plugins/sql/src/decode/mysql.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use serde_json::Value as JsonValue; -use sqlx::{mysql::MySqlValueRef, TypeInfo, Value, ValueRef}; +use sqlx::{mysql::MySqlValueRef, types::BigDecimal, TypeInfo, Value, ValueRef}; use time::{Date, OffsetDateTime, PrimitiveDateTime, Time}; use crate::Error; @@ -28,6 +28,13 @@ pub(crate) fn to_json(v: MySqlValueRef) -> Result { JsonValue::Null } } + "DECIMAL" | "NEWDECIMAL" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::String(v.to_string()) + } else { + JsonValue::Null + } + } "DOUBLE" => { if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { JsonValue::from(v)