This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch avro-3814/schema-resolution-union
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 94e5518b4cc703447b67d2f8b4ac3be5d23576b1
Author: Rik Heijdens <[email protected]>
AuthorDate: Fri Jul 28 11:48:03 2023 +0200

    AVRO-3814: Extend test case for validate_record
---
 lang/rust/avro/src/types.rs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lang/rust/avro/src/types.rs b/lang/rust/avro/src/types.rs
index 28809f0ea..c2fdf7075 100644
--- a/lang/rust/avro/src/types.rs
+++ b/lang/rust/avro/src/types.rs
@@ -1483,6 +1483,23 @@ mod tests {
         ])
         .validate(&schema));
 
+        // AVRO-3814 - when validating a record, extraneous fields should be 
ignored when schema resolution rules
+        // are applied.
+        let rs =
+            ResolvedSchema::try_from(vec![&schema]).expect("Schemata didn't 
successfully resolve");
+        let value = Value::Record(vec![
+            ("a".to_string(), Value::Long(42i64)),
+            ("b".to_string(), Value::String("foo".to_string())),
+            ("f".to_string(), Value::String("foo".to_string())), // extraneous 
field
+        ]);
+        assert!(value
+            .validate_internal(&schema, rs.get_names(), &schema.namespace(), 
false)
+            .is_some());
+        // However, when applying schema resolution rules, the extraneous 
should be ignored by the validation logic.
+        assert!(value
+            .validate_internal(&schema, rs.get_names(), &schema.namespace(), 
true)
+            .is_none());
+
         let value = Value::Record(vec![
             ("b".to_string(), Value::String("foo".to_string())),
             ("a".to_string(), Value::Long(42i64)),

Reply via email to