Commits

adamv committed 87a51fc

Added tests to show that .all.distinct() is the same as .all().

  • Participants
  • Parent commits d258bd0

Comments (0)

Files changed (1)

tests/test_main/slicing/models.py

             self.try_page(i, q)
 
 
-class LimitDistinctTable(models.Model):
+class DistinctTable(models.Model):
     s = models.CharField(max_length=10)
 
 
-class LimitDistinctTestCase(TestCase):
+class DistinctTestCase(TestCase):
     def testLimitDistinct(self):
-        T = LimitDistinctTable
+        T = DistinctTable
         T(s='abc').save()
         T(s='abc').save()
         T(s='abc').save()
 
         stuff = list(baseQ[2:4])
         self.assertEquals(stuff, [u'fgh', u'ijk'])
+
+    def testUnusedDistinct(self):
+        T = DistinctTable
+        T(s='abc').save()
+        T(s='abc').save()
+        T(s='abc').save()
+        T(s='def').save()
+        T(s='def').save()
+        T(s='fgh').save()
+        T(s='fgh').save()
+        T(s='fgh').save()
+        T(s='fgh').save()
+        T(s='ijk').save()
+        T(s='ijk').save()
+        T(s='xyz').save()
+        
+        baseQ = T.objects.distinct()
+        
+        stuff = list(baseQ)
+        self.assertEquals(len(stuff), 12)
+        
+        stuff = list(baseQ[:2])
+        self.assertEquals(
+            [o.s for o in stuff],
+            [u'abc', u'abc'])
+
+        stuff = list(baseQ[3:])
+        self.assertEquals(
+            [o.s for o in stuff], 
+            [u'def', u'def', u'fgh', u'fgh', u'fgh', u'fgh', u'ijk', u'ijk', u'xyz'])
+
+        stuff = list(baseQ[2:4])
+        self.assertEquals(
+            [o.s for o in stuff], 
+            [u'abc', u'def'])