Skip to content

Commit a3f9568

Browse files
authored
Merge pull request rails#42786 from composerinteralia/type-map-bugfix
Fix bug with TypeMap default values
2 parents aae83f4 + d30c85c commit a3f9568

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

activerecord/lib/active_record/type/type_map.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ def alias_type(key, target_key)
4040
end
4141

4242
protected
43-
def perform_fetch(lookup_key)
43+
def perform_fetch(lookup_key, &block)
4444
matching_pair = @mapping.reverse_each.detect do |key, _|
4545
key === lookup_key
4646
end
4747

4848
if matching_pair
4949
matching_pair.last.call(lookup_key)
5050
elsif @parent
51-
@parent.perform_fetch(lookup_key)
51+
@parent.perform_fetch(lookup_key, &block)
5252
else
5353
yield lookup_key
5454
end

activerecord/test/cases/type/type_map_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ def test_parent_fallback
143143
assert_equal boolean, mapping.lookup("boolean")
144144
end
145145

146+
def test_parent_fallback_for_default_type
147+
parent = klass.new
148+
mapping = klass.new(parent)
149+
150+
assert_kind_of Value, mapping.lookup(:undefined)
151+
end
152+
146153
private
147154
def klass
148155
TypeMap

0 commit comments

Comments
 (0)