ftelnov commented on code in PR #2266:
URL: https://github.com/apache/avro/pull/2266#discussion_r1219634813


##########
lang/rust/avro/src/schema.rs:
##########
@@ -434,21 +455,28 @@ impl<'s> ResolvedSchema<'s> {
                 }
                 Schema::Record(RecordSchema { name, fields, .. }) => {
                     let fully_qualified_name = 
name.fully_qualified_name(enclosing_namespace);
-                    if names_ref
+                    if self
+                        .names_ref
                         .insert(fully_qualified_name.clone(), schema)
                         .is_some()
                     {
                         return 
Err(Error::AmbiguousSchemaDefinition(fully_qualified_name));
                     } else {
                         let record_namespace = fully_qualified_name.namespace;
                         for field in fields {
-                            Self::from_internal(vec![&field.schema], 
names_ref, &record_namespace)?
+                            self.resolve(vec![&field.schema], 
&record_namespace, known_schemas)?
                         }
                     }
                 }
                 Schema::Ref { name } => {
                     let fully_qualified_name = 
name.fully_qualified_name(enclosing_namespace);
-                    if names_ref.get(&fully_qualified_name).is_none() {
+                    // first search for reference in current schema, then look 
into external references.
+                    let is_resolved_locally = 
self.names_ref.get(&fully_qualified_name).is_some();
+                    let is_resolved_with_known_schemas = known_schemas
+                        .as_ref()
+                        .map(|schemas| 
schemas.get(&fully_qualified_name).is_some())
+                        .unwrap_or(false);
+                    if !is_resolved_locally && !is_resolved_with_known_schemas 
{

Review Comment:
   I hope compiler would solve such a thing for us - mostly I wrote it to 
enhance readability. But yeah, you are right, we'd better state it explicitly



-- 
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]

Reply via email to