martin-g commented on code in PR #3466:
URL: https://github.com/apache/avro/pull/3466#discussion_r2408291972
##########
lang/js/test/test_schemas.js:
##########
@@ -2188,6 +2188,165 @@ describe('types', function () {
assert.equal(type._fields[1]._type._name, 'all.Alien');
});
+ it('namespace inheritance', function () {
+ // When nested types don't specify a namespace, they should inherit the
parent's
+ // namespace, but other nested types with explicit namespaces shouldn't
corrupt
+ // the inherited context.
+ var schema = {
+ type: 'record',
+ name: 'Parent',
+ namespace: 'parent.ns',
+ fields: [
+ {
+ name: 'child_field',
+ type: {
+ type: 'record',
+ name: 'Child', // No namespace - should inherit 'parent.ns'
+ fields: [{name: 'value', type: 'int'}]
+ }
+ },
+ {
+ name: 'other_field',
+ type: {
+ type: 'record',
+ name: 'Other',
+ namespace: 'different.ns', // Different namespace
+ fields: [{name: 'data', type: 'int'}]
+ }
+ },
+ {
+ name: 'reference_field',
+ type: 'Child' // Should resolve to 'parent.ns.Child'
+ }
+ ]
+ };
+
+ var type = createType(schema);
+ assert.equal(type.getName(), 'parent.ns.Parent');
+
+ var fields = type.getFields();
+ assert.equal(fields.length, 3);
+
+ // The critical test: reference_field should resolve Child to
parent.ns.Child
+ assert.equal(fields[2].getType().getName(), 'parent.ns.Child');
Review Comment:
Please add assertions for all fields
--
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]