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

struct defaults don't work correctly with all field types #37

Open
rogpeppe opened this issue Jan 24, 2020 · 0 comments
Open

struct defaults don't work correctly with all field types #37

rogpeppe opened this issue Jan 24, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@rogpeppe
Copy link
Contributor

The code to derive a default value from a Go struct is too naive. It doesn't cope when the JSON-formatted value isn't correct for Avro.

Here's a test case that fails:


tests: goTypeStructFieldWithEnum: {
	inSchema: {
		name: "R"
		type: "record"
		fields: []
	}
	goType: "R"
	goTypeBody: """
		struct {
			S S
		}
		type S struct {
			E Enum
		}
		type Enum int

		func (e Enum) String() string {
			return []string{"a", "b"}[e]
		}
	"""
	inData: {}
	outData: {
		S: E: "a"
	}
}
rogpeppe added a commit that referenced this issue Apr 6, 2020
This helps #37 but doesn't fix it entirely.

We also fail generation if there's a default value that doesn't
contain all the required fields, rather than generating invalid code.
@rogpeppe rogpeppe added the bug Something isn't working label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant