elad-yosifon opened a new issue, #247:
URL: https://github.com/apache/avro-rs/issues/247
I tried to play around with the proc-macro, and was able to make this test
pass:
```rust
#[test]
fn avro_flatten_fields() {
#[derive(Debug, Serialize, Deserialize, AvroSchema, Clone,
PartialEq)]
struct Nested {
a: bool,
}
#[derive(Debug, Serialize, Deserialize, AvroSchema, Clone,
PartialEq)]
struct Foo {
#[serde(flatten)]
nested: Nested,
b: i32,
}
let schema = r#"
{
"type":"record",
"name":"Foo",
"fields": [
{
"name":"a1",
"type":"boolean"
},
{
"name":"b",
"type":"int"
}
]
}
"#;
let schema = Schema::parse_str(schema).unwrap();
let derived_schema = Foo::get_schema();
if let Schema::Record(RecordSchema { name, fields, .. }) =
&derived_schema {
assert_eq!("Foo", name.fullname(None));
for field in fields {
match field.name.as_str() {
"a" | "b" => {
// expected
},
name @ _ => {
panic!("Unexpected field name '{name}'")
}
}
}
} else {
panic!(
"Foo schema must be a record schema: {derived_schema:?}"
)
}
assert_eq!(schema, derived_schema);
// deserializing not support
// serde_assert(Foo {
// nested: Nested { a: true },
// b: 321,
// });
}
```
but while running the other tests, it broke the `serde(rename)` related
tests since the schema code genrator changed in order to allow nested fields to
be pushed, and the tests verify the code generation.
I am having a hard time implementing this correctly mainly due to my lack of
familiarity with the project.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]