Commit b37e43b5 authored by jocuri%softhome.net's avatar jocuri%softhome.net

Patch for bug 253360: replace IF() with CASE WHEN for database compatibility;…

Patch for bug 253360: replace IF() with CASE WHEN for database compatibility; patch by Tomas Kopal <Tomas.Kopal@altap.cz>; r=vladd, a=justdave.
parent 7cea397f
...@@ -137,9 +137,9 @@ if ($action eq 'changeform') { ...@@ -137,9 +137,9 @@ if ($action eq 'changeform') {
my @groups; my @groups;
SendSQL("SELECT groups.id, groups.name, groups.description," . SendSQL("SELECT groups.id, groups.name, groups.description," .
" IF(group_group_map.member_id IS NOT NULL, 1, 0)," . " CASE WHEN group_group_map.member_id IS NOT NULL THEN 1 ELSE 0 END," .
" IF(B.member_id IS NOT NULL, 1, 0)," . " CASE WHEN B.member_id IS NOT NULL THEN 1 ELSE 0 END," .
" IF(C.member_id IS NOT NULL, 1, 0)" . " CASE WHEN C.member_id IS NOT NULL THEN 1 ELSE 0 END" .
" FROM groups" . " FROM groups" .
" LEFT JOIN group_group_map" . " LEFT JOIN group_group_map" .
" ON group_group_map.member_id = groups.id" . " ON group_group_map.member_id = groups.id" .
......
...@@ -135,9 +135,9 @@ sub EmitFormElements ($$$$) ...@@ -135,9 +135,9 @@ sub EmitFormElements ($$$$)
if($user ne "") { if($user ne "") {
print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Group Access:</TH><TD><TABLE><TR>"; print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Group Access:</TH><TD><TABLE><TR>";
SendSQL("SELECT groups.id, groups.name, groups.description, " . SendSQL("SELECT groups.id, groups.name, groups.description, " .
"MAX(IF(grant_type = " . GRANT_DIRECT . ", 1, 0))," . "MAX(CASE WHEN grant_type = " . GRANT_DIRECT . " THEN 1 ELSE 0 END)," .
"MAX(IF(grant_type = " . GRANT_DERIVED . ", 1, 0))," . "MAX(CASE WHEN grant_type = " . GRANT_DERIVED . " THEN 1 ELSE 0 END)," .
"MAX(IF(grant_type = " . GRANT_REGEXP . ", 1, 0))" . "MAX(CASE WHEN grant_type = " . GRANT_REGEXP . " THEN 1 ELSE 0 END)" .
"FROM groups " . "FROM groups " .
"LEFT JOIN user_group_map " . "LEFT JOIN user_group_map " .
"ON user_group_map.group_id = groups.id " . "ON user_group_map.group_id = groups.id " .
......
...@@ -572,9 +572,9 @@ sub ChangeStatus { ...@@ -572,9 +572,9 @@ sub ChangeStatus {
if ($::FORM{knob} eq 'reopen') { if ($::FORM{knob} eq 'reopen') {
# When reopening, we need to check whether the bug was ever # When reopening, we need to check whether the bug was ever
# confirmed or not # confirmed or not
$::query .= "bug_status = IF(everconfirmed = 1, " . $::query .= "bug_status = CASE WHEN everconfirmed = 1 THEN " .
SqlQuote($str) . ", " . SqlQuote($str) . " ELSE " .
SqlQuote($::unconfirmedstate) . ")"; SqlQuote($::unconfirmedstate) . " END";
} elsif (IsOpenedState($str)) { } elsif (IsOpenedState($str)) {
# Note that we cannot combine this with the above branch - here we # Note that we cannot combine this with the above branch - here we
# need to check if bugs.bug_status is open, (since we don't want to # need to check if bugs.bug_status is open, (since we don't want to
...@@ -603,11 +603,11 @@ sub ChangeStatus { ...@@ -603,11 +603,11 @@ sub ChangeStatus {
my @open_state = map(SqlQuote($_), OpenStates()); my @open_state = map(SqlQuote($_), OpenStates());
my $open_state = join(", ", @open_state); my $open_state = join(", ", @open_state);
$::query .= "bug_status = IF(bug_status IN($open_state), " . $::query .= "bug_status = CASE WHEN bug_status IN($open_state) THEN " .
"IF(everconfirmed = 1, " . "(CASE WHEN everconfirmed = 1 THEN " .
SqlQuote($str) . ", " . SqlQuote($str) . " ELSE " .
SqlQuote($::unconfirmedstate) . " ), " . SqlQuote($::unconfirmedstate) . " END) ELSE " .
"bug_status)"; "bug_status END";
} else { } else {
$::query .= "bug_status = " . SqlQuote($str); $::query .= "bug_status = " . SqlQuote($str);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment