This is an automated email from the ASF dual-hosted git repository. mgrigorov pushed a commit to branch avro-rs-219-bigdecimal-serde-features in repository https://gitbox.apache.org/repos/asf/avro-rs.git
commit 848a1716a3e990be1319a55b6b20cffaa2356e4c Author: Martin Tzvetanov Grigorov <[email protected]> AuthorDate: Tue Jul 1 14:43:02 2025 +0300 Fixes #219: Use `serde` as a feature for bigdecimal decimal See https://github.com/akubera/bigdecimal-rs/issues/151 Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> --- Cargo.lock | 1 - avro/Cargo.toml | 2 +- avro/tests/avro-rs-219.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a44497..5e00791 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,7 +150,6 @@ dependencies = [ "num-integer", "num-traits", "serde", - "serde_json", ] [[package]] diff --git a/avro/Cargo.toml b/avro/Cargo.toml index 507aae3..5988a46 100644 --- a/avro/Cargo.toml +++ b/avro/Cargo.toml @@ -54,7 +54,7 @@ name = "single" [dependencies] apache-avro-derive = { default-features = false, version = "0.19.0", path = "../avro_derive", optional = true } -bigdecimal = { default-features = false, version = "0.4.8", features = ["std", "serde-json"] } +bigdecimal = { default-features = false, version = "0.4.8", features = ["std", "serde"] } bon = { default-features = false, version = "3.6.4" } bzip2 = { version = "0.6.0", optional = true } crc32fast = { default-features = false, version = "1.4.2", optional = true } diff --git a/avro/tests/avro-rs-219.rs b/avro/tests/avro-rs-219.rs new file mode 100644 index 0000000..3796fbb --- /dev/null +++ b/avro/tests/avro-rs-219.rs @@ -0,0 +1,26 @@ +use serde::Deserialize; + +#[test] +fn avro_rs_219_failing_deserialization_due_to_bigdecimal_dependency() { + #[derive(Deserialize, PartialEq, Debug)] + struct S3 { + f1: Option<f64>, + + #[serde(flatten)] + inner: Inner, + } + + #[derive(Deserialize, PartialEq, Debug)] + struct Inner { + f2: f64, + } + + let test = r#"{ + "f1": 0.3, + "f2": 3.76 + }"#; + + let result = serde_json::from_str::<S3>(test); + println!("result : {result:#?}"); + result.unwrap(); +}
