From b99cbd1d893ff0a730ab7187f409bcdf3c6f4aeb Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Wed, 16 Mar 2005 08:27:14 +0000 Subject: Bug 174295: ANSI SQL requires all columns in SELECT to be in GROUP BY, unless they are in "aggregate" functions Patch By Tomas Kopal r=joel, a=myk --- Bugzilla/FlagType.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Bugzilla/FlagType.pm') diff --git a/Bugzilla/FlagType.pm b/Bugzilla/FlagType.pm index 5b681dc0c..8a6eb0272 100644 --- a/Bugzilla/FlagType.pm +++ b/Bugzilla/FlagType.pm @@ -120,7 +120,8 @@ sub match { my @tables = @base_tables; my @columns = @base_columns; my $having = ""; - + my $dbh = Bugzilla->dbh; + # Include a count of the number of flags per type if requested. if ($include_count) { push(@columns, "COUNT(flags.id)"); @@ -136,7 +137,9 @@ sub match { my $where_clause = "WHERE " . join(" AND ", @criteria); my $query = "$select_clause $from_clause $where_clause"; - $query .= " GROUP BY flagtypes.id " if ($include_count || $having ne ""); + $query .= " " . $dbh->sql_group_by('flagtypes.id', + join(', ', @base_columns[2..$#base_columns])) + if ($include_count || $having ne ""); $query .= " HAVING $having " if $having ne ""; $query .= " ORDER BY flagtypes.sortkey, flagtypes.name"; -- cgit v1.2.3-24-g4f1b