Skip to content
This repository
Browse code

Failing test for multiple annotation.

  • Loading branch information...
commit 2586758f2f7fa5ae1dc20c1b2847fa6c132f2233 1 parent ce738d6
Christian Ternus authored July 13, 2012

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  tests.py
8  tests.py
@@ -2478,6 +2478,14 @@ def test_annotate_custom_aggregate(self):
2478 2478
             'SELECT t1.`id`, t1.`title`, MAX(t2.`pub_date`) AS max_pub FROM `blog` AS t1 INNER JOIN `entry` AS t2 ON t1.`id` = t2.`blog_id` GROUP BY t1.`id`, t1.`title`', []
2479 2479
         ))
2480 2480
 
  2481
+    def test_annotate_multiple(self):
  2482
+        annotated = Blog.select().annotate(Entry).annotate(Entry, Max('pub_date', 'max_pub'))
  2483
+        self.assertSQLEqual(annotated.sql(), (
  2484
+            'SELECT t1."id", t1."title", COUNT(t2.`pk`) AS count, MAX(t2."pub_date") AS max_pub FROM "blog" AS t1 INNER JOIN "entry" AS t2 ON t1."id" = t2."blog_id" GROUP BY t1."id", t1."title"', []
  2485
+        ))
  2486
+        # No leftover asterisks
  2487
+        self.assertEqual(annotated.sql()[0].count('*'), 0)
  2488
+
2481 2489
     def test_aggregate(self):
2482 2490
         blergs = [Blog.create(title='b%d' % i) for i in range(10)]
2483 2491
 

0 notes on commit 2586758

Please sign in to comment.
Something went wrong with that request. Please try again.