From: lpsolit%gmail.com <> Date: Sun, 23 Sep 2007 02:11:48 +0000 (+0000) Subject: Bug 319466: commenter "contains" and "was me" fails with: Not unique table/alias... X-Git-Tag: bugzilla-3.0.3~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=879addae2def6a2e94add610c632ee353bc41727;p=thirdparty%2Fbugzilla.git Bug 319466: commenter "contains" and "was me" fails with: Not unique table/alias: 'longdescs_0' - Patch by GavinS r=joel a=LpSolit --- diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index ffe8e74f93..bd63e208e7 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -166,7 +166,7 @@ sub init { } if (grep($_ =~/AS (actual_time|percentage_complete)$/, @$fieldsref)) { - push(@supptables, "INNER JOIN longdescs AS ldtime " . + push(@supptables, "LEFT JOIN longdescs AS ldtime " . "ON ldtime.bug_id = bugs.bug_id"); } @@ -565,20 +565,20 @@ sub init { "^long_?desc,changedby" => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); my $id = login_to_id($v, THROW_ERROR); $term = "$table.who = $id"; }, "^long_?desc,changedbefore" => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); $term = "$table.bug_when < " . $dbh->quote(SqlifyDate($v)); }, "^long_?desc,changedafter" => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); $term = "$table.bug_when > " . $dbh->quote(SqlifyDate($v)); }, @@ -598,7 +598,7 @@ sub init { { $extra = "AND $table.isprivate < 1"; } - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON bugs.bug_id = $table.bug_id $extra"); # Create search terms to add to the SELECT and WHERE clauses. @@ -704,7 +704,7 @@ sub init { { $extra = "AND $table.isprivate < 1"; } - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id $extra"); $f = "$table.thetext"; }, @@ -716,13 +716,13 @@ sub init { { $extra = "AND $table.isprivate < 1"; } - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id $extra"); $f = "$table.isprivate"; }, "^work_time,changedby" => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); my $id = login_to_id($v, THROW_ERROR); $term = "(($table.who = $id"; @@ -730,21 +730,21 @@ sub init { }, "^work_time,changedbefore" => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); $term = "(($table.bug_when < " . $dbh->quote(SqlifyDate($v)); $term .= ") AND ($table.work_time <> 0))"; }, "^work_time,changedafter" => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); $term = "(($table.bug_when > " . $dbh->quote(SqlifyDate($v)); $term .= ") AND ($table.work_time <> 0))"; }, "^work_time," => sub { my $table = "longdescs_$chartid"; - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); $f = "$table.work_time"; }, @@ -776,7 +776,7 @@ sub init { if(lsearch(\@fields, "bugs.remaining_time") == -1) { push(@fields, "bugs.remaining_time"); } - push(@supptables, "INNER JOIN longdescs AS $table " . + push(@supptables, "LEFT JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); my $expression = "(100 * ((SUM($table.work_time) * COUNT(DISTINCT $table.bug_when) / @@ -1427,21 +1427,20 @@ sub init { my $suppstring = "bugs"; my @supplist = (" "); foreach my $str (@supptables) { - if (!$suppseen{$str}) { - if ($str =~ /^(LEFT|INNER|RIGHT)\s+JOIN/i) { - $str =~ /^(.*?)\s+ON\s+(.*)$/i; - my ($leftside, $rightside) = ($1, $2); - if ($suppseen{$leftside}) { - $supplist[$suppseen{$leftside}] .= " AND ($rightside)"; - } else { - $suppseen{$leftside} = scalar @supplist; - push @supplist, " $leftside ON ($rightside)"; - } + + if ($str =~ /^(LEFT|INNER|RIGHT)\s+JOIN/i) { + $str =~ /^(.*?)\s+ON\s+(.*)$/i; + my ($leftside, $rightside) = ($1, $2); + if (defined $suppseen{$leftside}) { + $supplist[$suppseen{$leftside}] .= " AND ($rightside)"; } else { - # Do not accept implicit joins using comma operator - # as they are not DB agnostic - ThrowCodeError("comma_operator_deprecated"); + $suppseen{$leftside} = scalar @supplist; + push @supplist, " $leftside ON ($rightside)"; } + } else { + # Do not accept implicit joins using comma operator + # as they are not DB agnostic + ThrowCodeError("comma_operator_deprecated"); } } $suppstring .= join('', @supplist);