View Issue Details

IDProjectCategoryView StatusLast Update
0013228mantisbttime trackingpublic2014-09-23 18:05
Reporterhartois Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.6 
Target Version1.2.7Fixed in Version1.2.7 
Summary0013228: APPLICATION ERROR 0000401 Bug in SQL query in bugnote_api.php
Description

On Mantis 1.2.6 with Postgresql 9.0.4 DB
APPLICATION ERROR 0000401
Запрос к базе данных не удался. Получена ошибка - #-1: ERROR: column "u.realname" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT username, realname, summary, bn.bug_id, SUM(time_trac...
^, запрос: SELECT username, realname, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking
FROM mantis_user_table u, mantis_bugnote_table bn, mantis_bug_table b
WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
AND bn.date_submitted >= 1312837200 AND bn.date_submitted <= 1312923599
GROUP BY bn.bug_id, u.id, u.username, b.summary
ORDER BY bn.bug_id.

Additional Information

Patch to fix attached

Tagspatch
Attached Files
mantis-1.2.7-bugnote_api.patch (735 bytes)   
diff -urN mantis.old/core/bugnote_api.php mantis.new/core/bugnote_api.php
--- mantis.old/core/bugnote_api.php     2011-07-26 16:49:10.000000000 +0300
+++ mantis.new/core/bugnote_api.php     2011-08-09 22:34:25.000000000 +0300
@@ -675,7 +675,7 @@
                        FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table b
                        WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
                        $t_project_where $t_from_where $t_to_where
-                       GROUP BY bn.bug_id, u.id, u.username, b.summary
+                       GROUP BY bn.bug_id, u.id, u.username, b.summary, u.realname
                        ORDER BY bn.bug_id";
 
        $result = db_query( $query );
mantis-bugnote_api.patch (780 bytes)   
--- mantis.old/core/bugnote_api.php	2011-07-26 16:49:10.000000000 +0300
+++ mantis/core/bugnote_api.php	2011-08-10 09:33:16.000000000 +0300
@@ -614,7 +614,7 @@
 				WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND
 				bn.bug_id = '$c_bug_id'
 				$t_from_where $t_to_where
-				GROUP BY u.id, u.username";
+				GROUP BY u.id, u.username, u.realname";
 
 	$result = db_query( $query );
 
@@ -675,7 +675,7 @@
 			FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table b
 			WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
 			$t_project_where $t_from_where $t_to_where
-			GROUP BY bn.bug_id, u.id, u.username, b.summary
+			GROUP BY bn.bug_id, u.id, u.username, b.summary, u.realname
 			ORDER BY bn.bug_id";
 
 	$result = db_query( $query );
mantis-bugnote_api.patch (780 bytes)   

Relationships

related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 

Activities

hartois

hartois

2011-08-10 04:57

reporter   ~0029434

mantis-bugnote_api.patch contains more odim fix in the same file

dregad

dregad

2011-08-10 07:38

developer   ~0029435

Fix committed. Thanks for the bug report !

grangeway

grangeway

2013-04-05 17:57

reporter   ~0036411

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

Related Changesets

MantisBT: master 96532dbe

2011-08-10 00:10

dregad


Details Diff
Fix 0013228: SQL error in bugnote_api.php with PostgreSQL

ERROR: column "u.realname" must appear in the GROUP BY clause or be used in an
aggregate function

Bug was introduced in release 1.2.6, commit c4c0a01e1f715aea775a36d3a6c7bc8bd74b5b8b.
A new column was added to 2 SQL statements' SELECT clause, but the GROUP BY
was not updated to match.

This passed testing, as MySQL is more (too?) permissive and allows the SELECT
clause to refer to ungrouped columns that are not in aggregate functions.

This commit also removes unnecessary "u.id" column from the group by clause.
Affected Issues
0013228
mod - core/bugnote_api.php Diff File

MantisBT: master-1.2.x c6ab7a0c

2011-08-10 00:10

dregad


Details Diff
Fix 0013228: SQL error in bugnote_api.php with PostgreSQL

ERROR: column "u.realname" must appear in the GROUP BY clause or be used in an
aggregate function

Bug was introduced in release 1.2.6, commit c4c0a01e1f715aea775a36d3a6c7bc8bd74b5b8b.
A new column was added to 2 SQL statements' SELECT clause, but the GROUP BY
was not updated to match.

This passed testing, as MySQL is more (too?) permissive and allows the SELECT
clause to refer to ungrouped columns that are not in aggregate functions.

This commit also removes unnecessary "u.id" column from the group by clause.
Affected Issues
0013228
mod - core/bugnote_api.php Diff File