|
| 1 | +*********** |
| 2 | +Mongoid 9.0 |
| 3 | +*********** |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 2 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +This page describes significant changes and improvements in Mongoid 9.0. |
| 14 | +The complete list of releases is available `on GitHub |
| 15 | +<https://github.com/mongodb/mongoid/releases>`_ and `in JIRA |
| 16 | +<https://jira.mongodb.org/projects/MONGOID?selectedItem=com.atlassian.jira.jira-projects-plugin:release-page>`_; |
| 17 | +please consult GitHub releases for detailed release notes and JIRA for |
| 18 | +the complete list of issues fixed in each release, including bug fixes. |
| 19 | + |
| 20 | + |
| 21 | +Raise AttributeNotLoaded error when accessing fields omitted from query projection |
| 22 | +---------------------------------------------------------------------------------- |
| 23 | + |
| 24 | +When attempting to access a field on a model instance which was |
| 25 | +excluded with the ``.only`` or ``.without`` query projections methods |
| 26 | +when the instance was loaded, Mongoid will now raise a |
| 27 | +``Mongoid::Errors::AttributeNotLoaded`` error. |
| 28 | + |
| 29 | +.. code-block:: ruby |
| 30 | + |
| 31 | + Band.only(:name).first.label |
| 32 | + #=> raises Mongoid::Errors::AttributeNotLoaded |
| 33 | + |
| 34 | + Band.without(:label).first.label = 'Sub Pop Records' |
| 35 | + #=> raises Mongoid::Errors::AttributeNotLoaded |
| 36 | + |
| 37 | +In earlier Mongoid versions, the same conditions would raise an |
| 38 | +``ActiveModel::MissingAttributeError``. Please check your code for |
| 39 | +any Mongoid-specific usages of this class, and change them to |
| 40 | +``Mongoid::Errors::AttributeNotLoaded``. Note additionally that |
| 41 | +``AttributeNotLoaded`` inherits from ``Mongoid::Errors::MongoidError``, |
| 42 | +while ``ActiveModel::MissingAttributeError`` does not. |
0 commit comments