Add tests for distcint with count
This commit is contained in:
		@@ -485,6 +485,13 @@ class TestQuerySetDistinct(BaseQuerySetUsage):
 | 
			
		||||
        q = TestModel.objects.distinct(['test_id']).filter(test_id__in=[52])
 | 
			
		||||
        self.assertEqual(len(q), 0)
 | 
			
		||||
 | 
			
		||||
    def test_distinct_with_explicit_count(self):
 | 
			
		||||
        q = TestModel.objects.distinct(['test_id'])
 | 
			
		||||
        self.assertEqual(q.count(), 3)
 | 
			
		||||
 | 
			
		||||
        q = TestModel.objects.distinct(['test_id']).filter(test_id__in=[1, 2])
 | 
			
		||||
        self.assertEqual(q.count(), 2)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestQuerySetOrdering(BaseQuerySetUsage):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -64,6 +64,9 @@ class SelectStatementTests(unittest.TestCase):
 | 
			
		||||
        ss = SelectStatement('table', distinct_fields=['field1', 'field2'])
 | 
			
		||||
        self.assertEqual(six.text_type(ss), 'SELECT DISTINCT "field1", "field2" FROM table')
 | 
			
		||||
 | 
			
		||||
        ss = SelectStatement('table', distinct_fields=['field1'], count=True)
 | 
			
		||||
        self.assertEqual(six.text_type(ss), 'SELECT DISTINCT COUNT("field1") FROM table')
 | 
			
		||||
 | 
			
		||||
    def test_context(self):
 | 
			
		||||
        ss = SelectStatement('table')
 | 
			
		||||
        ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user