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') {
my @groups;
SendSQL("SELECT groups.id, groups.name, groups.description," .
" IF(group_group_map.member_id IS NOT NULL, 1, 0)," .
" IF(B.member_id IS NOT NULL, 1, 0)," .
" IF(C.member_id IS NOT NULL, 1, 0)" .
" CASE WHEN group_group_map.member_id IS NOT NULL THEN 1 ELSE 0 END," .
" CASE WHEN B.member_id IS NOT NULL THEN 1 ELSE 0 END," .
" CASE WHEN C.member_id IS NOT NULL THEN 1 ELSE 0 END" .
" FROM groups" .
" LEFT JOIN group_group_map" .
" ON group_group_map.member_id = groups.id" .
......
......@@ -135,9 +135,9 @@ sub EmitFormElements ($$$$)
if($user ne "") {
print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Group Access:</TH><TD><TABLE><TR>";
SendSQL("SELECT groups.id, groups.name, groups.description, " .
"MAX(IF(grant_type = " . GRANT_DIRECT . ", 1, 0))," .
"MAX(IF(grant_type = " . GRANT_DERIVED . ", 1, 0))," .
"MAX(IF(grant_type = " . GRANT_REGEXP . ", 1, 0))" .
"MAX(CASE WHEN grant_type = " . GRANT_DIRECT . " THEN 1 ELSE 0 END)," .
"MAX(CASE WHEN grant_type = " . GRANT_DERIVED . " THEN 1 ELSE 0 END)," .
"MAX(CASE WHEN grant_type = " . GRANT_REGEXP . " THEN 1 ELSE 0 END)" .
"FROM groups " .
"LEFT JOIN user_group_map " .
"ON user_group_map.group_id = groups.id " .
......
......@@ -572,9 +572,9 @@ sub ChangeStatus {
if ($::FORM{knob} eq 'reopen') {
# When reopening, we need to check whether the bug was ever
# confirmed or not
$::query .= "bug_status = IF(everconfirmed = 1, " .
SqlQuote($str) . ", " .
SqlQuote($::unconfirmedstate) . ")";
$::query .= "bug_status = CASE WHEN everconfirmed = 1 THEN " .
SqlQuote($str) . " ELSE " .
SqlQuote($::unconfirmedstate) . " END";
} elsif (IsOpenedState($str)) {
# 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
......@@ -603,11 +603,11 @@ sub ChangeStatus {
my @open_state = map(SqlQuote($_), OpenStates());
my $open_state = join(", ", @open_state);
$::query .= "bug_status = IF(bug_status IN($open_state), " .
"IF(everconfirmed = 1, " .
SqlQuote($str) . ", " .
SqlQuote($::unconfirmedstate) . " ), " .
"bug_status)";
$::query .= "bug_status = CASE WHEN bug_status IN($open_state) THEN " .
"(CASE WHEN everconfirmed = 1 THEN " .
SqlQuote($str) . " ELSE " .
SqlQuote($::unconfirmedstate) . " END) ELSE " .
"bug_status END";
} else {
$::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