Use COALESCE instead of case construct
authorJoshua Rüsweg <josh@bastelstu.be>
Sat, 12 May 2018 20:58:35 +0000 (22:58 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Sun, 13 May 2018 12:08:32 +0000 (14:08 +0200)
See #2508

wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php

index 2873cc77f65aa9f2827d7035f23b1fd0bdd977ed..cdbe94b994ade4ddbcdc738bf273b60de843d7e8 100644 (file)
@@ -184,7 +184,7 @@ class ReactionHandler extends SingletonFactory {
                
                if (WCF::getUser()->userID) {
                        $sql = "SELECT          like_object.*,
-                                               CASE WHEN like_table.reactionTypeID IS NOT NULL THEN like_table.reactionTypeID ELSE 0 END AS reactionTypeID
+                                               COALESCE(like_table.reactionTypeID, 0) AS reactionTypeID
                                FROM            wcf".WCF_N."_like_object like_object
                                LEFT JOIN       wcf".WCF_N."_like like_table
                                ON              (like_table.objectTypeID = like_object.objectTypeID
@@ -560,7 +560,7 @@ class ReactionHandler extends SingletonFactory {
         */
        protected function loadLikeStatus(LikeObject $likeObject, User $user) {
                $sql = "SELECT          like_object.likes, like_object.dislikes, like_object.cumulativeLikes,
-                                       CASE WHEN like_table.likeValue IS NOT NULL THEN like_table.reactionTypeID ELSE 0 END AS reactionTypeID
+                                       COALESCE(like_table.reactionTypeID, 0) AS reactionTypeID
                        FROM            wcf".WCF_N."_like_object like_object
                        LEFT JOIN       wcf".WCF_N."_like like_table
                        ON              (like_table.objectTypeID = ?