You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "Ten (Jira)" <ji...@apache.org> on 2022/12/17 21:21:00 UTC
[jira] [Updated] (AVRO-3692) Serde flatten is not supported when deserializing
[ https://issues.apache.org/jira/browse/AVRO-3692?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ten updated AVRO-3692:
----------------------
Description:
The following:
{code:java}
#[test]
fn test_from_value_struct_flatten() {
#[derive(Deserialize, PartialEq, Debug)]
struct S1 {
f1: String,
#[serde(flatten)]
inner: S2,
}
#[derive(Deserialize, PartialEq, Debug)]
struct S2 {
f2: String,
}
let expected = S1 {
f1: "Hello".to_owned(),
inner: S2 {
f2: "World".to_owned(),
},
}; let test = Value::Record(vec![
("f1".to_owned(), "Hello".into()),
("f2".to_owned(), "World".into()),
]);
let final_value: S1 = from_value(&test).unwrap();
assert_eq!(final_value, expected);
} {code}
fails to deserialize.
This is due to serde hinting for map deserialization when structs contain flatten. It is super easy to fix, I'm opening a PR.
was:
The following:
```rust
#[test]
fn test_from_value_struct_flatten() {
#[derive(Deserialize, PartialEq, Debug)]
struct S1 {
f1: String,
#[serde(flatten)]
inner: S2,
}
#[derive(Deserialize, PartialEq, Debug)]
struct S2 {
f2: String,
}
let expected = S1 {
f1: "Hello".to_owned(),
inner: S2 {
f2: "World".to_owned(),
},
};
let test = Value::Record(vec![
("f1".to_owned(), "Hello".into()),
("f2".to_owned(), "World".into()),
]);
let final_value: S1 = from_value(&test).unwrap();
assert_eq!(final_value, expected);
}
```
fails to deserialize.
This is due to serde hinting for map deserialization when structs contain flatten. It is super easy to fix, I'm opening a PR.
> Serde flatten is not supported when deserializing
> -------------------------------------------------
>
> Key: AVRO-3692
> URL: https://issues.apache.org/jira/browse/AVRO-3692
> Project: Apache Avro
> Issue Type: Improvement
> Components: rust
> Reporter: Ten
> Priority: Trivial
>
> The following:
> {code:java}
> #[test]
> fn test_from_value_struct_flatten() {
> #[derive(Deserialize, PartialEq, Debug)]
> struct S1 {
> f1: String,
> #[serde(flatten)]
> inner: S2,
> }
> #[derive(Deserialize, PartialEq, Debug)]
> struct S2 {
> f2: String,
> }
> let expected = S1 {
> f1: "Hello".to_owned(),
> inner: S2 {
> f2: "World".to_owned(),
> },
> }; let test = Value::Record(vec![
> ("f1".to_owned(), "Hello".into()),
> ("f2".to_owned(), "World".into()),
> ]);
> let final_value: S1 = from_value(&test).unwrap();
> assert_eq!(final_value, expected);
> } {code}
> fails to deserialize.
> This is due to serde hinting for map deserialization when structs contain flatten. It is super easy to fix, I'm opening a PR.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)