lib/avro/schema_compatibility.rb in avro-1.10.2 vs lib/avro/schema_compatibility.rb in avro-1.11.0

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the @@ -44,32 +45,26 @@ if w_type == :union || r_type == :union return true end if w_type == r_type - return true if Schema::PRIMITIVE_TYPES_SYM.include?(r_type) + return readers_schema.match_schema?(writers_schema) if Schema::PRIMITIVE_TYPES_SYM.include?(r_type) case r_type - when :record - return readers_schema.match_fullname?(writers_schema.fullname) - when :error - return readers_schema.match_fullname?(writers_schema.fullname) when :request return true - when :fixed - return readers_schema.match_fullname?(writers_schema.fullname) && - writers_schema.size == readers_schema.size - when :enum - return readers_schema.match_fullname?(writers_schema.fullname) when :map return match_schemas(writers_schema.values, readers_schema.values) when :array return match_schemas(writers_schema.items, readers_schema.items) + else + return readers_schema.match_schema?(writers_schema) end end # Handle schema promotion + # rubocop:disable Lint/DuplicateBranch if w_type == :int && INT_COERCIBLE_TYPES_SYM.include?(r_type) return true elsif w_type == :long && LONG_COERCIBLE_TYPES_SYM.include?(r_type) return true elsif w_type == :float && r_type == :double @@ -77,11 +72,16 @@ elsif w_type == :string && r_type == :bytes return true elsif w_type == :bytes && r_type == :string return true end + # rubocop:enable Lint/DuplicateBranch - return false + if readers_schema.respond_to?(:match_schema?) + readers_schema.match_schema?(writers_schema) + else + false + end end class Checker SIMPLE_CHECKS = Schema::PRIMITIVE_TYPES_SYM.dup.add(:fixed).freeze