mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
[1.6.x] 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.
Backpatch of 83554b018e from master.
This commit is contained in:
@@ -387,6 +387,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