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

Uniqueness Validation no longer uses $ne for duplication check, allows for index usage.

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Hi all,

      A change to the uniqueness validator to no longer use the $ne query selector, which misses any indexes. Instead opting to return all matching records and then removing itself from possible conflicts.

      Had to enable always removing the current document's id in the check for embedded documents since they are present in the relationship before they are persisted. Could opt to load another instance of the parent document for the check, but would only affect the untested case where the '_id' and tested attribute contain the same value in embeds_many relationships.

      Thanks again,
      Dave

            Assignee:
            Unassigned Unassigned
            Reporter:
            dave@davekrupinski.com Dave Krupinski
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: