martin-g commented on code in PR #397:
URL: https://github.com/apache/avro-rs/pull/397#discussion_r2681797989
##########
avro/src/schema.rs:
##########
@@ -2765,17 +2767,49 @@ pub mod derive {
name: "duration".to_string(),
namespace: enclosing_namespace.clone(),
};
- named_schemas
- .entry(name.clone())
- .or_insert(Schema::Duration(FixedSchema {
- name,
+ if named_schemas.contains_key(&name) {
+ Schema::Ref { name }
+ } else {
+ let schema = Schema::Duration(FixedSchema {
+ name: name.clone(),
aliases: None,
doc: None,
size: 12,
default: None,
attributes: Default::default(),
- }))
- .clone()
+ });
+ named_schemas.insert(name.clone(), schema.clone());
+ schema
+ }
+ }
+ }
+
+ impl AvroSchemaComponent for uuid::Uuid {
+ /// The schema is [`Schema::Uuid`] with the name `uuid`.
+ ///
+ /// The underlying schema is [`Schema::Fixed`] with a size of 16.
+ fn get_schema_in_ctxt(
+ named_schemas: &mut Names,
+ enclosing_namespace: &Namespace,
+ ) -> Schema {
+ let name = Name {
+ name: "uuid".to_string(),
Review Comment:
Good point!
I should probably just try it myself but it is easier to ask you 😅
What is the produced schema for this struct ?
```rust
#[derive(AvroSchema)]
struct Foo {
#[serde(rename="baz")]
bar: Duration
}
```
--
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]