bartkl / metamorph

Metamorph is a Clojure libary that enables the generation of an Avro schema from a given input SHACL model.
https://bartkl.github.io/metamorph/
Apache License 2.0
2 stars 3 forks source link

Consider stripping the generated default values for `:required` fields #43

Closed bartkl closed 2 years ago

bartkl commented 2 years ago

Lancaster generates default values for required record fields. I believe this to be undesired behavior, and have submitted an issue here: https://github.com/deercreeklabs/lancaster/issues/20

Chad brings up an interesting discussion there, which I intend to have here.

This issue, however, is simply about short-term remedy of the problem that validation is made impossible by the generation of a default value.

So: change the code such that required fields will have no default values, allowing for validation by end users.

bartkl commented 2 years ago

It's debatable whether this is actually a bug, but since it is a current feature that doesn't work as desired, I think "bug" serves as a decent description.

bartkl commented 2 years ago

By the way, note this in the Avro spec:

default: A default value for this field, only used when reading instances that lack the field for schema evolution purposes. The presence of a default value does not make the field optional at encoding time.

bartkl commented 2 years ago

After having read more about Avro and schema evolution, it is almost certainly desired to have default values for fields.

I've laid it out in more detail here.