extract_attribute() fails to correctly handle cases with a numeric hash key. When the current code finds a numeric hash key, but sees that 'src' is NOT an array, it returns that the field does not exist.
This PR adds a test case that fails for the old code, and then passes with the new code.
PR: https://github.com/mongodb/mongoid/pull/4964
Test Output (Old Code)
1) Matcher.extract_attribute traversal.yml numeric hash key matching the split position has the expected exists flag
Failure/Error: actual[0].should == expected_exists
expected: true
got: false (using ==)
Diff:
@@ -1 +1 @@
-true
+false
# ./spec/mongoid/matcher/extract_attribute_spec.rb:33:in `block (6 levels) in <top (required)>'
2) Matcher.extract_attribute traversal.yml numeric hash key matching the split position has the expected value
Failure/Error: actual[1].should == expected_value
expected: true
got: nil (using ==)
# ./spec/mongoid/matcher/extract_attribute_spec.rb:37:in `block (6 levels) in <top (required)>'
XYZ examples, 2 failures
Test Output (New Code)
XYZ examples, 0 failures
- related to
-
MONGOID-5069 Support numeric path components resolving to hash keys under arrays when embedded matching
-
- Closed
-