avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1848) Can't use null or false defaults in Ruby
Date Sun, 04 Sep 2016 00:59:20 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15461986#comment-15461986

ASF subversion and git services commented on AVRO-1848:

Commit d7e12314832f1ef58f87d2f5106ac6b49c5a0be9 in avro's branch refs/heads/master from [~theturtle32]
[ https://git-wip-us.apache.org/repos/asf?p=avro.git;h=d7e1231 ]

AVRO-1848: Ruby: Fix handling of falsey default values.

> 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
>             Fix For: 1.8.2
>   Original Estimate: 2h
>  Remaining Estimate: 2h
> When calling {{to_avro}} on an {{Avro::Schema::Field}} instance (part of calling {{to_avro}}
on an instance of {{Avro::Schema::RecordSchema}}), 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, because {{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

View raw message