@@ -57,6 +57,40 @@ changed in Mongoid 8.0:
57
57
Please refer to :ref:`configuration option <configuration-options>` for
58
58
the description and effects of each of these options.
59
59
60
+ Storing Uncastable Types and the ``validate_attribute_types`` Flag
61
+ ------------------------------------------------------------------
62
+
63
+ In Mongoid 8, Mongoid deals with "uncastable values" based on the values of the
64
+ ``validates_attribute_types`` flag. If the ``validates_attribute_types`` flag
65
+ is set to true, an ``InvalidValue`` error is raise, and if it is set to false
66
+ a ``nil`` is written. See the secion on :ref:`Uncastable Values <uncastable-values>`
67
+ for more details.
68
+
69
+ Some ``mongoize`` methods were also changed to perform consistently with rails
70
+ and the other mongoize methods. The following is a table of the changes in
71
+ functionality:
72
+
73
+ +--------------+------------------------+------------------------+-------------------+
74
+ | Field Type | Situation | Previous Functionality | New Functionality |
75
+ +==============+========================+========================+===================+
76
+ | Integer/Float| When a non-numeric | return ``nil`` | return ``42`` |
77
+ | | string starts with a | | |
78
+ | | number: "42bogus" | | |
79
+ +--------------+------------------------+------------------------+-------------------+
80
+ | Boolean | When a non-boolean | return ``false`` | return ``nil`` or |
81
+ | | string is assigned: | | raise |
82
+ | | "bogus value" | | ``InvalidError`` |
83
+ +--------------+------------------------+------------------------+-------------------+
84
+ | Symbol | When a value that does | return ``nil`` | return ``nil`` or |
85
+ | | not respond to | | raise |
86
+ | | ``to_sym`` is | | ``InvalidError`` |
87
+ | | assigned: ``[]`` | | |
88
+ +--------------+------------------------+------------------------+-------------------+
89
+ | All Other | When an uncastable | undefined behavior, | return ``nil`` or |
90
+ | Types | value is assigned | occasionally raises | raise |
91
+ | | | ``NoMethodError`` | ``InvalidError`` |
92
+ +--------------+------------------------+------------------------+-------------------+
93
+
60
94
61
95
Order of Callback Invocation
62
96
----------------------------
0 commit comments