[
https://issues.apache.org/jira/browse/AVRO-1848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15292287#comment-15292287
]
ASF GitHub Bot commented on AVRO-1848:
--------------------------------------
GitHub user theturtle32 opened a pull request:
https://github.com/apache/avro/pull/96
AVRO-1848: Fix handling of falsey default values in Ruby
https://issues.apache.org/jira/browse/AVRO-1848
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dollarshaveclub/avro FIX-AVRO-1848
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/avro/pull/96.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #96
----
commit d33ab415caea7e9bd8c596e74c5c4ce4245682a0
Author: Brian McKelvey <[email protected]>
Date: 2016-05-19T22:43:58Z
AVRO-1848: Fix handling of falsey default values in Ruby
----
> 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
> Labels: easyfix
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> 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)