| 321 | # Regression for 11916 - extra params + aggregation creates incorrect SQL |
| 322 | >>> shortest_book_sql = ' \\ |
| 323 | ... SELECT name \\ |
| 324 | ... FROM aggregation_regress_book b \\ |
| 325 | ... WHERE b.publisher_id = aggregation_regress_publisher.id \\ |
| 326 | ... ORDER BY b.pages \\ |
| 327 | ... LIMIT 1 ' |
| 328 | >>> # tests that this query does not raise a DatabaseError due to the full |
| 329 | >>> # subselect being (erroneously) added to the GROUP BY parameters |
| 330 | >>> Publisher.objects.extra(select={ |
| 331 | ... 'name_of_shortest_book': shortest_book_sql, |
| 332 | ... }).annotate(total_books=Count('book')).order_by('name').values_list('id', 'total_books', 'name_of_shortest_book') |
| 333 | [(1, 2, u'Practical Django Projects'), (5, 0, None), (4, 1, u'Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp'), (3, 2, u'Python Web Development with Django'), (2, 1, u'Sams Teach Yourself Django in 24 Hours')] |