mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #21126 -- QuerySet value conversion failure
A .annotate().select_related() query resulted in misaligned rows vs columns for compiler.resolve_columns() method. Report & patch by Michael Manfre.
This commit is contained in:
@@ -393,6 +393,17 @@ class AggregationTests(TestCase):
|
||||
qs = Entries.objects.annotate(clue_count=Count('clues__ID'))
|
||||
self.assertQuerysetEqual(qs, [])
|
||||
|
||||
def test_boolean_conversion(self):
|
||||
# Aggregates mixed up ordering of columns for backend's convert_values
|
||||
# method. Refs #21126.
|
||||
e = Entries.objects.create(Entry='foo')
|
||||
c = Clues.objects.create(EntryID=e, Clue='bar')
|
||||
qs = Clues.objects.select_related('EntryID').annotate(Count('ID'))
|
||||
self.assertQuerysetEqual(
|
||||
qs, [c], lambda x: x)
|
||||
self.assertEqual(qs[0].EntryID, e)
|
||||
self.assertIs(qs[0].EntryID.Exclude, False)
|
||||
|
||||
def test_empty(self):
|
||||
# Regression for #10089: Check handling of empty result sets with
|
||||
# aggregates
|
||||
|
||||
Reference in New Issue
Block a user