Commits

Anonymous committed 87a51fc

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

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'])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.