-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Validations
-
None
A set is a container that does not preserve order of elements. Mongoid persists sets as arrays which do preserve order. When a uniqueness validation is requested on a set, the elements should be checked in such a way that two arrays which have the same elements in different order are considered the same set.
A possible complication here is that an array permits duplicate elements while a set does not. It is possible that a field in the database contains duplicates via manual modification. (On the other hand, if such a database value existed today, it would also not validate correctly against a set on the client side.)
Unlike https://jira.mongodb.org/browse/MONGOID-5375 which requests an order-insensitive option for validating uniquness of arrays, sets should always be validated without regard for order of elements.
id lists in HABTM associations are effectively sets, and should be validated the same way sets are (without regard for order of elements).
- related to
-
MONGOID-5375 validates_uniqueness_of Array field should have order_insensitive option
- Backlog