fastavro gives a default value for unions with nulls that don't have a default value #49
This is somewhat related to #48. Given this example schema:
the following should fail:
However, it does not, giving a default value of null to a field ('y') without a default value.
This stems from the use of .get(), which returns None if the key is not found.
This is just mixing up the lack of a value, with a value of null. Instead, the code should check for the field's existence in the datum, and return false if it doesn't exist.
This is related to #37, in that having write_record call validate() on itself would catch this. Although I imagine the overhead might raise some ire, so there are some options.
Some pull requests will be made in a bit.
The text was updated successfully, but these errors were encountered:
Create a `NoValue` sentinel object for this case. Previously, `None` would be deduced, but Python's `None` is conflated with the Avro type `null` and can causes issues with `union` records that contain a `null` type. See fastavro#49
For any `x = object()`, `bool(x) == True`. However we do not want the special `NoValue` sentinel to be mistaken as any valid type. Implement a `__bool__` method on the `_NoValue` class to raise a TypeError. See: fastavro#49