Kriskras99 commented on code in PR #382:
URL: https://github.com/apache/avro-rs/pull/382#discussion_r2662153578
##########
avro/src/schema.rs:
##########
@@ -2629,7 +2663,6 @@ pub mod derive {
impl_schema!(f64, Schema::Double);
impl_schema!(String, Schema::String);
impl_schema!(uuid::Uuid, Schema::Uuid(UuidSchema::String));
- impl_schema!(core::time::Duration, Schema::Duration);
Review Comment:
The old code generated the following schema:
```json
{"type":{"name":"duration","type":"fixed","size":12}}
```
I think it would be good to keep it:
```rust
impl AvroSchemaComponent for core::time::Duration {
fn get_schema_in_ctxt(
named_schemas: &mut HashMap<String, Schema>,
enclosing_namespace: &Namespace,
) -> Schema {
let name = Name {
name: "duration".to_string(),
namespace: enclosing_namespace.clone(),
};
named_schemas
.entry(name.to_string())
.or_insert(Schema::Duration(FixedSchema {
name,
aliases: None,
doc: None,
size: 12,
default: None,
attributes: Default::default(),
}))
.clone()
}
}
```
If `enclosing_namespace` is `Some` the old schema would stay the same
(namespace would not be added), while in the above code it would be added. So
that is a change, but I do think it's for the better.
--
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]