Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Union Generation for map[string]interface{} in Avro Schemas #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gskchaitanya
Copy link

The current implementation of the avrogo code generator incorrectly omits union information for fields defined as map[string]interface{} in Avro schemas. This occurs specifically in cases where the union type is ["null", map[string]T]. The omission of this union information leads to incorrect code generation, not reflecting the intended schema's flexibility and complexity.

Example of Issue:
A field defined as mapTest *map[string]interface{} 'json:"mapTest"' in the Avro schema incorrectly omits the necessary union type information in the generated Go code.

Solution:
This pull request introduces a fix in the union type generation logic within the writeUnionInfo function. It specifically addresses the handling of map[string]interface{} fields to ensure the proper inclusion of union type information.

The fix involves updating the logic to recognize and correctly handle the ["null", map[string]T] union case, ensuring that it's not omitted during code generation. This change allows the generated Go code to accurately represent the Avro schema's structure and the intended flexibility of the map[string]interface{} field.

// If the union is ["null", map[string]T] then we can't omit the union
	// Example: mapTest *map[string]interface{} `json:"mapTest"` will omit the union without this check for map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants