Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5389

Uniqueness validation of Sets and HABTM associations should be order-insensitive

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Validations
    • Labels:
      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).

            Assignee:
            Unassigned Unassigned
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: