Commits

Martin Skala  committed c0a0a5d

Get rid of duplicate attributes if looking for attributes with exact match

  • Participants
  • Parent commits 7f4023d

Comments (0)

Files changed (1)

File django_roa/db/query.py

 
         # keep the custom attribute name of model for later use
         custom_pk = self.model._meta.pk.attname
-        # check PK, ID or custom PK attribute name for exact match filters
-        exact_match = [attr for attr in ['id__exact', 'pk__exact', '%s__exact' % custom_pk] if attr in kwargs.keys()]
+        # search PK, ID or custom PK attribute name for exact match and get set
+        # of unique matches
+        attributes_set = set(attr for attr in ['id__exact', 'pk__exact', '%s__exact' % custom_pk] if attr in kwargs.keys())
+        exact_match = list(attributes_set)
         # common way of getting particular object
         if kwargs.keys() == ['id']:
             return self._get_from_id_or_pk(id=kwargs['id'])