From 46aba0e761e99db24b5de10f13bbc108fdc982a4 Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Tue, 25 Oct 2005 02:21:02 +0000 Subject: Bug 313209: Oracle requires "CASE WHEN" around boolean expressions in the SELECT column list Patch By Lance Larsh r=mkanat, a=justdave --- Bugzilla/Bug.pm | 4 +++- Bugzilla/User.pm | 10 +++++++--- chart.cgi | 4 +++- editproducts.cgi | 5 +++-- globals.pl | 4 +++- process_bug.cgi | 4 +++- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index c08703789..d094b8eae 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -24,6 +24,7 @@ # Dave Miller # Max Kanat-Alexander # Frédéric Buclin +# Lance Larsh package Bugzilla::Bug; @@ -547,7 +548,8 @@ sub groups { my $grouplist = Bugzilla->user->groups_as_string; my $sth = $dbh->prepare( "SELECT DISTINCT groups.id, name, description," . - " bug_group_map.group_id IS NOT NULL," . + " CASE WHEN bug_group_map.group_id IS NOT NULL" . + " THEN 1 ELSE 0 END," . " CASE WHEN groups.id IN($grouplist) THEN 1 ELSE 0 END," . " isactive, membercontrol, othercontrol" . " FROM groups" . diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 9b99428a6..744dbd34a 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -25,6 +25,7 @@ # Shane H. W. Travis # Max Kanat-Alexander # Gervase Markham +# Lance Larsh ################################################################################ # Module Initialization @@ -509,7 +510,8 @@ sub can_enter_product { trick_taint($product_name); # Checks whether the user has access to the product. - my $has_access = $dbh->selectrow_array('SELECT group_id IS NULL + my $has_access = $dbh->selectrow_array('SELECT CASE WHEN group_id IS NULL + THEN 1 ELSE 0 END FROM products LEFT JOIN group_control_map ON group_control_map.product_id = products.id @@ -527,8 +529,10 @@ sub can_enter_product { # Checks whether the product is open for new bugs and # has at least one component and one version. my ($is_open, $has_version) = - $dbh->selectrow_array('SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END, - versions.value IS NOT NULL + $dbh->selectrow_array('SELECT CASE WHEN disallownew = 0 + THEN 1 ELSE 0 END, + CASE WHEN versions.value IS NOT NULL + THEN 1 ELSE 0 END FROM products INNER JOIN components ON components.product_id = products.id diff --git a/chart.cgi b/chart.cgi index 2b8d39b56..566d0541f 100755 --- a/chart.cgi +++ b/chart.cgi @@ -19,6 +19,7 @@ # Rights Reserved. # # Contributor(s): Gervase Markham +# Lance Larsh # Glossary: # series: An individual, defined set of data plotted over time. @@ -207,7 +208,8 @@ sub assertCanEdit { return if UserInGroup("admin"); my $dbh = Bugzilla->dbh; - my $iscreator = $dbh->selectrow_array("SELECT creator = ? FROM series " . + my $iscreator = $dbh->selectrow_array("SELECT CASE WHEN creator = ? " . + "THEN 1 ELSE 0 END FROM series " . "WHERE series_id = ?", undef, $::userid, $series_id); $iscreator || ThrowUserError("illegal_series_edit"); diff --git a/editproducts.cgi b/editproducts.cgi index 9b188f231..13614f269 100755 --- a/editproducts.cgi +++ b/editproducts.cgi @@ -25,6 +25,7 @@ # Gavin Shelley # Fr��ic Buclin # Greg Hendricks +# Lance Larsh # # Direct any questions on this source code to # @@ -624,7 +625,7 @@ if ($action eq 'updategroupcontrols') { foreach my $groupid (@now_na) { my $count = 0; SendSQL("SELECT bugs.bug_id, - (lastdiffed >= delta_ts) + CASE WHEN (lastdiffed >= delta_ts) THEN 1 ELSE 0 END FROM bugs, bug_group_map WHERE group_id = $groupid AND bug_group_map.bug_id = bugs.bug_id @@ -658,7 +659,7 @@ if ($action eq 'updategroupcontrols') { foreach my $groupid (@now_mandatory) { my $count = 0; SendSQL("SELECT bugs.bug_id, - (lastdiffed >= delta_ts) + CASE WHEN (lastdiffed >= delta_ts) THEN 1 ELSE 0 END FROM bugs LEFT JOIN bug_group_map ON bug_group_map.bug_id = bugs.bug_id diff --git a/globals.pl b/globals.pl index ebbce4c16..e7e3f7521 100644 --- a/globals.pl +++ b/globals.pl @@ -25,6 +25,7 @@ # Joel Peshkin # Dave Lawrence # Max Kanat-Alexander +# Lance Larsh # Contains some global variables and routines used throughout bugzilla. @@ -734,7 +735,8 @@ sub get_legal_field_values { sub BugInGroupId { my ($bugid, $groupid) = (@_); PushGlobalSQLState(); - SendSQL("SELECT bug_id != 0 FROM bug_group_map + SendSQL("SELECT CASE WHEN bug_id != 0 THEN 1 ELSE 0 END + FROM bug_group_map WHERE bug_id = $bugid AND group_id = $groupid"); my $bugingroup = FetchOneColumn(); diff --git a/process_bug.cgi b/process_bug.cgi index dc119179c..9f556cc0a 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -25,6 +25,7 @@ # Myk Melez # Jeff Hedlund # Frédéric Buclin +# Lance Larsh # Implementation notes for this file: # @@ -1730,7 +1731,8 @@ foreach my $id (@idlist) { SendSQL("SELECT DISTINCT groups.id, isactive, " . "oldcontrolmap.membercontrol, newcontrolmap.membercontrol, " . "CASE WHEN groups.id IN ($grouplist) THEN 1 ELSE 0 END, " . - "bug_group_map.group_id IS NOT NULL " . + "CASE WHEN bug_group_map.group_id IS NOT NULL " . + "THEN 1 ELSE 0 END " . "FROM groups " . "LEFT JOIN group_control_map AS oldcontrolmap " . "ON oldcontrolmap.group_id = groups.id " . -- cgit v1.2.3-24-g4f1b