Kriskras99 commented on code in PR #569:
URL: https://github.com/apache/avro-rs/pull/569#discussion_r3565001955
##########
avro/src/schema/record/schema.rs:
##########
@@ -82,11 +82,13 @@ impl<S: record_schema_builder::State>
RecordSchemaBuilder<S> {
/// Calculate the lookup table for the given fields.
fn calculate_lookup_table(fields: &[RecordField]) -> BTreeMap<String, usize> {
- fields
+ let map: BTreeMap<_, _> = fields
.iter()
.enumerate()
.map(|(i, field)| (field.name.clone(), i))
- .collect()
+ .collect();
+ assert_eq!(map.len(), fields.len(), "Duplicate field names found");
Review Comment:
I'm not sure we should silence these in release mode, this will fail in the
serializer otherwise (with `Details::FieldNameDuplicate`) but it will be far
removed from the reason (an incorrect schema).
It would be nice if we could return an error, but `#[bon(skip)` doesn't
allow that.
--
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]