Ten created AVRO-3692:
-------------------------

             Summary: 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


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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to