avromatic 0.21.0 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3735485da34dc63c50632195a8def3420b62e6f
4
- data.tar.gz: b08e6330739ce4a9f91345e99f5410a40e23a7b6
3
+ metadata.gz: 0abfee6a816f939b561c744c5ac49c5a6b2d484e
4
+ data.tar.gz: 1d43dfd2df53bf40b0f571cdce873bc5055c3837
5
5
  SHA512:
6
- metadata.gz: 1f64185bde09c296a5020c04cccae9ce9b6aaf2a42d2d64f2cd5210e2b323fbc298b00e6b729985494e76ae55f36d4188f4d5dbd80004d068bd34849f2d296fc
7
- data.tar.gz: 57482d3feca518adfe945f7af8b92d31a3dadc85b609d97d99d62454aaa90a3bd368eb932f7a02f6dbb634cd301b9c054091be7010339e267f9b8dc78234bfb9
6
+ metadata.gz: 802e7634ae80d35338e596db5bba3155d1378a533921716b9e14f0685ae8f94cc7d7f578820c55f16d1c1cfeb5a8c7f1bb0f2e875001732856fbc97ef3d7a92f
7
+ data.tar.gz: 2fa0d4b40bbafa7f15627f877536d72d9413dee8c5009f0d46ac00dd78d8efc7ed9be234d00fc069e70ed3b4baf0d5a1087234405d1717371820c2db15aef55f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # avromatic changelog
2
2
 
3
+ ## v0.21.1
4
+ - Fix a bug in the optimization of optional union decoding.
5
+
3
6
  ## v0.21.0
4
7
  - Remove monkey-patches for `AvroTurf::ConfluentSchemaRegistry` and
5
8
  `FakeConfluentSchemaRegistryServer` and depend on `avro_schema_registry-client`
data/avromatic.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'avromatic/version'
@@ -34,7 +35,7 @@ Gem::Specification.new do |spec|
34
35
  spec.add_development_dependency 'avro-builder', '>= 0.12.0'
35
36
  # For AvroSchemaRegistry::FakeServer
36
37
  spec.add_development_dependency 'sinatra'
37
- spec.add_development_dependency 'salsify_rubocop', '~> 0.47.0'
38
+ spec.add_development_dependency 'salsify_rubocop', '~> 0.48.0'
38
39
  spec.add_development_dependency 'overcommit', '0.35.0'
39
40
  spec.add_development_dependency 'appraisal'
40
41
  end
@@ -20,7 +20,16 @@ module Avromatic
20
20
  self.class.match_schemas(writers_schema, s)
21
21
  end
22
22
 
23
- union_info = { UNION_MEMBER_INDEX => rs_index }
23
+ optional = readers_schema.schemas.first.type_sym == :null
24
+ union_info = if readers_schema.schemas.size == 2 && optional
25
+ # Avromatic does not treat the union of null and 1 other type as a union
26
+ {}
27
+ elsif optional
28
+ # Avromatic does not treat the null of an optional field as part of the union
29
+ { UNION_MEMBER_INDEX => rs_index - 1 }
30
+ else
31
+ { UNION_MEMBER_INDEX => rs_index }
32
+ end
24
33
 
25
34
  return read_data(writers_schema, readers_schema.schemas[rs_index], decoder, union_info) if rs_index
26
35
  raise Avro::IO::SchemaMatchException.new(writers_schema, readers_schema)
@@ -144,6 +144,9 @@ module Avromatic
144
144
  end
145
145
 
146
146
  def union_field_class(field_type)
147
+ null_index = field_type.schemas.index { |schema| schema.type_sym == :null }
148
+ raise 'a null type in a union must be the first member' if null_index && null_index > 0
149
+
147
150
  field_classes = field_type.schemas.reject { |schema| schema.type_sym == :null }
148
151
  .map { |schema| avro_field_class(schema) }
149
152
 
@@ -1,3 +1,3 @@
1
1
  module Avromatic
2
- VERSION = '0.21.0'.freeze
2
+ VERSION = '0.21.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avromatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-10 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -210,14 +210,14 @@ dependencies:
210
210
  requirements:
211
211
  - - "~>"
212
212
  - !ruby/object:Gem::Version
213
- version: 0.47.0
213
+ version: 0.48.0
214
214
  type: :development
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
217
217
  requirements:
218
218
  - - "~>"
219
219
  - !ruby/object:Gem::Version
220
- version: 0.47.0
220
+ version: 0.48.0
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: overcommit
223
223
  requirement: !ruby/object:Gem::Requirement