Unable to access embedded fields in projected query results

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 7.1.4
    • Affects Version/s: 7.1.2
    • Component/s: None
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      A change was made in Mongoid 7.1 that causes embedded fields accessors not to work on projected query results.

      For example, say you have a Person document with a Passport document embedded in the passport field. The following code raises an error:

      person = Person.only(:passport).first
      number = person.passport.number
      # ActiveModel::MissingAttributeError:
      #      Missing attribute: 'number'.
      

      Mongoid does not recognize the embedded field as one of the projected attributes.

              Assignee:
              Oleg Pudeyev (Inactive)
              Reporter:
              Emily Giurleo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: