Bug 302785: [PostgreSQL] Bugzilla cannot order a buglist by number of votes - Patch by Fr�d�ric Buclin <LpSolit@gmail.com> r=joel a=justdave

This commit is contained in:
lpsolit%gmail.com 2005-10-06 20:42:41 +00:00
Родитель be887b9ad2
Коммит b7856c3202
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -1418,10 +1418,11 @@ sub init {
next if ($field =~ /(AVG|SUM|COUNT|MAX|MIN|VARIANCE)\s*\(/i || next if ($field =~ /(AVG|SUM|COUNT|MAX|MIN|VARIANCE)\s*\(/i ||
$field =~ /^\d+$/ || $field eq "bugs.bug_id" || $field =~ /^\d+$/ || $field eq "bugs.bug_id" ||
$field =~ /^relevance/); $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); 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)); $query .= ") " . $dbh->sql_group_by("bugs.bug_id", join(', ', @groupby));