avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian McKelvey (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AVRO-1848) Can't use null or false defaults in Ruby
Date Fri, 20 May 2016 00:22:12 GMT

     [ https://issues.apache.org/jira/browse/AVRO-1848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Brian McKelvey updated AVRO-1848:
---------------------------------
    Description: 
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.

  was:
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.


> 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::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
(v6.3.4#6332)

Mime
View raw message