]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 302785: [PostgreSQL] Bugzilla cannot order a buglist by number of votes - Patch...
authorlpsolit%gmail.com <>
Fri, 7 Oct 2005 03:48:08 +0000 (03:48 +0000)
committerlpsolit%gmail.com <>
Fri, 7 Oct 2005 03:48:08 +0000 (03:48 +0000)
Bugzilla/Search.pm

index 56d2846f37c176e27d2a69ff9a05efe99f0754d1..0e9a56b0f55ad490d4e6f9f0ef0d4f4ee5c103aa 100644 (file)
@@ -1380,10 +1380,11 @@ sub init {
         next if ($field =~ /(AVG|SUM|COUNT|MAX|MIN|VARIANCE)\s*\(/i ||
                  $field =~ /^\d+$/ || $field eq "bugs.bug_id" ||
                  $field =~ /^relevance/);
-        if ($field =~ /.*AS\s+(\w+)$/i) {
+        # The structure of fields is of the form:
+        # [foo AS] {bar | bar.baz} [ASC | DESC]
+        # Only the mandatory part bar OR bar.baz is of interest
+        if ($field =~ /(?:.*\s+AS\s+)?(\w+(\.\w+)?)(?:\s+(ASC|DESC))?$/i) {
             push(@groupby, $1) if !grep($_ eq $1, @groupby);
-        } else {
-            push(@groupby, $field) if !grep($_ eq $field, @groupby);
         }
     }
     $query .= ") " . $dbh->sql_group_by("bugs.bug_id", join(', ', @groupby));