-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 7.1.2
-
Component/s: None
-
None
-
(copied to CRM)
-
Fully Compatible
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.
- is caused by
-
MONGOID-2681 Using #only with embedded documents sets omitted fields to default values
- Closed
- is duplicated by
-
MONGOID-4983 Embedded documents fetch using `only` raises MissingAttributeError
- Closed
-
MONGOID-5010 Mongoid 7.1 upgrade documentation missing breaking change
- Closed
- is related to
-
MONGOID-5032 Hash attribute access/read_attribute fails on embedded field when parent loaded with only
- Closed
- links to