id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os
146,PATCH: SQL Bug on summarizers.py (PostgreSQL as the backend),Pedro Algarvio aka s0undt3ch <ufs@…>,cmlenz,"I seem to have hit an SQL bug while running bitten(trunk) on trac 0.10.3 with PostgreSQL as the backend.

{{{
ERROR: column ""item_lines.value"" must appear in the GROUP BY clause or be used in an aggregate function
SQL state: 42803
}}}


Here's the patch that at least makes it work again.
{{{
#!diff
Index: bitten/trac_ext/summarizers.py
===================================================================
--- bitten/trac_ext/summarizers.py      (revision 377)
+++ bitten/trac_ext/summarizers.py      (working copy)
@@ -78,7 +78,7 @@
         cursor = db.cursor()
         cursor.execute(""""""
 SELECT item_name.value AS unit, item_file.value AS file,
-       item_lines.value AS loc, item_percentage.value AS cov
+       max(item_lines.value) AS loc, max(item_percentage.value) AS cov
 FROM bitten_report AS report
  LEFT OUTER JOIN bitten_report_item AS item_name
   ON (item_name.report=report.id AND item_name.name='name')
@@ -93,7 +93,7 @@
       item_percentage.item=item_name.item AND
       item_percentage.name='percentage')
 WHERE category='coverage' AND build=%s AND step=%s
-GROUP BY file, unit ORDER BY unit"""""", (build.id, step.name))
+GROUP BY file, item_name.value ORDER BY item_name.value"""""", (build.id, step.name))

         data = []
         total_loc, total_cov = 0, 0
}}}",enhancement,closed,major,0.6,Trac plugin,dev,fixed,,,Linux
