mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #23395 -- Limited line lengths to 119 characters.
This commit is contained in:
committed by
Tim Graham
parent
84b0a8d2aa
commit
b1e33ceced
@@ -16,10 +16,26 @@ class RawQueryTests(TestCase):
|
||||
cls.a2 = Author.objects.create(first_name='Jill', last_name='Doe', dob=date(1920, 4, 2))
|
||||
cls.a3 = Author.objects.create(first_name='Bob', last_name='Smith', dob=date(1986, 1, 25))
|
||||
cls.a4 = Author.objects.create(first_name='Bill', last_name='Jones', dob=date(1932, 5, 10))
|
||||
cls.b1 = Book.objects.create(title='The awesome book', author=cls.a1, paperback=False, opening_line='It was a bright cold day in April and the clocks were striking thirteen.')
|
||||
cls.b2 = Book.objects.create(title='The horrible book', author=cls.a1, paperback=True, opening_line='On an evening in the latter part of May a middle-aged man was walking homeward from Shaston to the village of Marlott, in the adjoining Vale of Blakemore, or Blackmoor.')
|
||||
cls.b3 = Book.objects.create(title='Another awesome book', author=cls.a1, paperback=False, opening_line='A squat grey building of only thirty-four stories.')
|
||||
cls.b4 = Book.objects.create(title='Some other book', author=cls.a3, paperback=True, opening_line='It was the day my grandmother exploded.')
|
||||
cls.b1 = Book.objects.create(
|
||||
title='The awesome book', author=cls.a1, paperback=False,
|
||||
opening_line='It was a bright cold day in April and the clocks were striking thirteen.',
|
||||
)
|
||||
cls.b2 = Book.objects.create(
|
||||
title='The horrible book', author=cls.a1, paperback=True,
|
||||
opening_line=(
|
||||
'On an evening in the latter part of May a middle-aged man '
|
||||
'was walking homeward from Shaston to the village of Marlott, '
|
||||
'in the adjoining Vale of Blakemore, or Blackmoor.'
|
||||
),
|
||||
)
|
||||
cls.b3 = Book.objects.create(
|
||||
title='Another awesome book', author=cls.a1, paperback=False,
|
||||
opening_line='A squat grey building of only thirty-four stories.',
|
||||
)
|
||||
cls.b4 = Book.objects.create(
|
||||
title='Some other book', author=cls.a3, paperback=True,
|
||||
opening_line='It was the day my grandmother exploded.',
|
||||
)
|
||||
cls.c1 = Coffee.objects.create(brand='dunkin doughnuts')
|
||||
cls.c2 = Coffee.objects.create(brand='starbucks')
|
||||
cls.r1 = Reviewer.objects.create()
|
||||
@@ -211,7 +227,12 @@ class RawQueryTests(TestCase):
|
||||
pass
|
||||
|
||||
def test_annotations(self):
|
||||
query = "SELECT a.*, count(b.id) as book_count FROM raw_query_author a LEFT JOIN raw_query_book b ON a.id = b.author_id GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id"
|
||||
query = (
|
||||
"SELECT a.*, count(b.id) as book_count "
|
||||
"FROM raw_query_author a "
|
||||
"LEFT JOIN raw_query_book b ON a.id = b.author_id "
|
||||
"GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id"
|
||||
)
|
||||
expected_annotations = (
|
||||
('book_count', 3),
|
||||
('book_count', 0),
|
||||
|
||||
Reference in New Issue
Block a user