diff options
author | mkanat%kerio.com <> | 2005-04-16 07:37:23 +0000 |
---|---|---|
committer | mkanat%kerio.com <> | 2005-04-16 07:37:23 +0000 |
commit | 666d1f4bf2c3fe31dba8cdcac742c5fc4ddeb986 (patch) | |
tree | f76d334b50e5839cef0ddc36e9211dbf4757f4b9 /Bugzilla | |
parent | 6a16fc78cccc69d3bb8a1871b2eca9ff29211da0 (diff) | |
download | bugs-666d1f4bf2c3fe31dba8cdcac742c5fc4ddeb986.tar bugs-666d1f4bf2c3fe31dba8cdcac742c5fc4ddeb986.tar.gz bugs-666d1f4bf2c3fe31dba8cdcac742c5fc4ddeb986.tar.bz2 bugs-666d1f4bf2c3fe31dba8cdcac742c5fc4ddeb986.tar.xz bugs-666d1f4bf2c3fe31dba8cdcac742c5fc4ddeb986.zip |
Bug 286360: ANSI SQL does not allow aliases to be used in HAVING clause
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=myk, r=joel, a=myk
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Search.pm | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 0283b7f76..bebbfd94a 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -600,8 +600,8 @@ sub init { # (see http://bugzilla.mozilla.org/show_bug.cgi?id=145588#c35). my $select_term = "(SUM($term1)/COUNT($term1) + $term2) AS relevance"; -
- # add the column not used in aggregate function explicitly
+ + # add the column not used in aggregate function explicitly push(@groupby, 'bugs.short_desc'); # Users can specify to display the relevance field, in which case @@ -726,10 +726,15 @@ sub init { my $table = "longdescs_$chartid"; push(@supptables, "INNER JOIN longdescs AS $table " . "ON $table.bug_id = bugs.bug_id"); - my $field = "(100*((SUM($table.work_time)*COUNT(DISTINCT $table.bug_when)/COUNT(bugs.bug_id))/((SUM($table.work_time)*COUNT(DISTINCT $table.bug_when)/COUNT(bugs.bug_id))+bugs.remaining_time))) AS percentage_complete_$table"; - push(@fields, $field); - push(@having, - "percentage_complete_$table $oper " . &::SqlQuote($v)); + my $expression = "(100 * ((SUM($table.work_time) * + COUNT(DISTINCT $table.bug_when) / + COUNT(bugs.bug_id)) / + ((SUM($table.work_time) * + COUNT(DISTINCT $table.bug_when) / + COUNT(bugs.bug_id)) + + bugs.remaining_time)))"; + push(@having, "$expression $oper " . &::SqlQuote($v)); + push(@groupby, "bugs.remaining_time"); } $term = "0=0"; }, @@ -814,9 +819,9 @@ sub init { # If the numbers are the same, all flags match the condition, # so this bug should be included. if ($t =~ m/not/) { - push(@fields, "SUM(CASE WHEN $ff IS NOT NULL THEN 1 ELSE 0 END) AS allflags_$chartid"); - push(@fields, "SUM(CASE WHEN $term THEN 1 ELSE 0 END) AS matchingflags_$chartid"); - push(@having, "allflags_$chartid = matchingflags_$chartid"); + push(@having, + "SUM(CASE WHEN $ff IS NOT NULL THEN 1 ELSE 0 END) = " . + "SUM(CASE WHEN $term THEN 1 ELSE 0 END)"); $term = "0=0"; } }, |