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

Uniqueness validation with scope on aliased fields

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.6
    • Affects Version/s: None
    • Component/s: None

      Scope doesn't seem to work with aliased field names. For example,

      class Address
        # municipality, postal_code and country symbols are field aliases
        validates :street_line_1, :uniqueness => { :scope => [:municipality,:postal_code,:country] }
      end
      

      Will result in duplicates.
      Changing the aliased scope fields to their proper names fixes the issue.

      class Address
        # it's all good now
        validates :street_line_1, :uniqueness => { :scope => [:a,:b,:c] }
      end
      

            Assignee:
            durran Durran Jordan
            Reporter:
            wielgosm wielgosm
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: