Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5069

Support numeric path components resolving to hash keys under arrays when embedded matching

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.2
    • Affects Version/s: 7.2.1
    • Component/s: Query
    • Labels:
      None
    • Fully Compatible

      Embedded matching in Mongoid failed to match documents where hashes with numeric keys were nested under arrays. For example:

        document: 
          foo:
            -
              '42':
                bar: 1
        query:
          foo.42.bar: 1
      

      In this case, 42 is meant to be interpreted as the hash key, not as an array index.

      https://jira.mongodb.org/browse/MONGOID-5063 earlier repaired a related problem of numeric keys being not matchable when they were in simple hashes (without array expansion being involved).

      -------

      Original report:

      Mongoid::Matcher.expand_attribute() does not correctly handle numeric hash keys inside expanded arrays. This PR provides the fix + test cases: https://github.com/mongodb/mongoid/pull/4969

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            dalton.black@braze.com Dalton Black
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: