]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 319466: commenter "contains" and "was me" fails with: Not unique table/alias...
authorlpsolit%gmail.com <>
Sun, 23 Sep 2007 02:11:48 +0000 (02:11 +0000)
committerlpsolit%gmail.com <>
Sun, 23 Sep 2007 02:11:48 +0000 (02:11 +0000)
Bugzilla/Search.pm

index ffe8e74f931bfb8392d0bc2e8057ec591b4f9771..bd63e208e737a474a918ff98df34859e9dbeff0d 100644 (file)
@@ -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);