dry-schema icon indicating copy to clipboard operation
dry-schema copied to clipboard

Key map contains duplicates on inheritance

Open pyromaniac opened this issue 2 years ago • 3 comments

Describe the bug

When one schema is inherited from another one and redefines some fields, those fields got duplicated in the schema's key_map.

To Reproduce

class Foo < Dry::Schema::Params
  define do
    required(:foo).filled(:integer)
  end
end

class Bar < Foo
  define do
    required(:foo).filled(:string)
  end
end

Foo.new.key_map
#=> #<Dry::Schema::KeyMap["foo"]>
Bar.new.key_map
#=> #<Dry::Schema::KeyMap["foo", "foo"]>

Expected behavior

I would expect the exact list of schema keys in the keymap.

pyromaniac avatar Aug 29 '21 18:08 pyromaniac

@solnic, @flash-gordon I can even work on the PR fixing this. I just need to know your opinion, folks. Does it look like a bug to you or an intended behavior?

pyromaniac avatar Sep 17 '21 10:09 pyromaniac

@pyromaniac 💯 that wasn't planned to work like this :)

flash-gordon avatar Sep 17 '21 11:09 flash-gordon

This was finally fixed in 1.10.5

solnic avatar Sep 21 '22 08:09 solnic

Thank you so much!

pyromaniac avatar Mar 04 '24 04:03 pyromaniac