Brian McKelvey created AVRO-1848:
------------------------------------
Summary: Can't use null or false defaults in Ruby
Key: AVRO-1848
URL: https://issues.apache.org/jira/browse/AVRO-1848
Project: Avro
Issue Type: Bug
Components: ruby
Affects Versions: 1.8.0
Environment: Any
Reporter: Brian McKelvey
Priority: Critical
When calling {{to_avro}} on an {{Avro::Field}} instance (part of calling
{{to_avro}} on an instance of {{Avro::Schema}}), it will not include the
default value definition if the default value is falsey.
The offending code is:
{code:ruby}
def to_avro(names=Set.new)
{'name' => name, 'type' => type.to_avro(names)}.tap do |avro|
avro['default'] = default if default
avro['order'] = order if order
end
end
{code}
Using the {{if default}} conditional predicate here is inappropriate, as is
relying on `nil` values to represent no default, as `null` in JSON maps to
`nil` in Ruby.
This is a critical show-stopper to using AvroTurf with the Confluent Schema
Registry because it is quietly uploading incorrect schemas, causing downstream
readers to behave incorrectly and also causing the schema registry to reject
new schema versions as incompatible when they are actually just fine if the
falsey default values are included when submitting the schema to the registry.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)