You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/12/18 19:58:00 UTC
[jira] [Commented] (AVRO-3692) Serde flatten is not supported when deserializing
[ https://issues.apache.org/jira/browse/AVRO-3692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17649076#comment-17649076 ]
ASF subversion and git services commented on AVRO-3692:
-------------------------------------------------------
Commit a02e974181724a8abb9120424e9d8590b0d852a4 in avro's branch refs/heads/master from Ten0
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=a02e97418 ]
AVRO-3692: [rust] Make serde deserializer support serde flatten (#2024)
* Make serde deserializer support serde flatten
* Update test name to include avro ticket id
Co-authored-by: Martin Grigorov <ma...@users.noreply.github.com>
* give more details in not-record-nor-map error
Co-authored-by: Martin Grigorov <ma...@users.noreply.github.com>
> 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
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> 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)