Kriskras99 commented on code in PR #448:
URL: https://github.com/apache/avro-rs/pull/448#discussion_r2745692555
##########
avro_derive/src/lib.rs:
##########
@@ -146,15 +164,13 @@ fn get_struct_schema_def(
} else if field_attrs.flatten {
// Inline the fields of the child record at runtime, as we
don't have access to
// the schema here.
- let flatten_ty = &field.ty;
+ let get_record_fields =
+ get_field_get_record_fields_expr(&field,
field_attrs.with)?;
record_field_exprs.push(quote! {
- if let
::apache_avro::schema::Schema::Record(::apache_avro::schema::RecordSchema {
fields, .. }) = #flatten_ty::get_schema() {
- for mut field in fields {
- field.position = schema_fields.len();
- schema_fields.push(field)
- }
+ if let Some(flattened_fields) = #get_record_fields {
+ schema_fields.extend(flattened_fields)
Review Comment:
I have fixed it in the flatten code. An alternative is adding an extra field
to `get_record_fields_in_ctxt` that gives the starting position, I think that
might be a better option?
--
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]