cat-in-136 / redmine_hearts

a redmine plugin which provides intra-Redmine Like/Fav reactions
https://www.redmine.org/plugins/redmine_hearts
GNU General Public License v2.0
33 stars 3 forks source link

error 500 encountered when click on Like on the tab #18

Closed zhongw closed 5 years ago

zhongw commented 5 years ago

the following message displayed:

Started GET "/projects/itc/hearts" for 10.103.0.12 at 2019-01-03 16:13:55 +0800
Processing by HeartsController#index as HTML
  Parameters: {"project_id"=>"itc"}
  Current user: abc(id=5)
Completed 500 Internal Server Error in 48ms (ActiveRecord: 16.9ms)

ActiveRecord::StatementInvalid (Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'redmine.hearts.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT  `hearts`.* FROM `hearts` WHERE ((((((`hearts`.`heartable_type` = 'Board' AND `hearts`.`heartable_id` IN (SELECT `boards`.`id` FROM `boards` INNER JOIN `projects` ON `projects`.`id` = `boards`.`project_id` WHERE (projects.status <> 9 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='boards')) AND (boards.project_id IN (4))) OR `hearts`.`heartable_type` = 'Message' AND `hearts`.`heartable_id` IN (SELECT `messages`.`id` FROM `messages` INNER JOIN `boards` ON `boards`.`id` = `messages`.`board_id` INNER JOIN `projects` ON `projects`.`id` = `boards`.`project_id` WHERE (projects.status <> 9 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='boards')) AND (boards.project_id IN (4)))) OR `hearts`.`heartable_type` = 'WikiPage' AND `hearts`.`heartable_id` IN (SELECT `wiki_pages`.`id` FROM `wiki_pages` INNER JOIN `wikis` ON `wikis`.`id` = `wiki_pages`.`wiki_id` WHERE (wikis.project_id IN (4)))) OR `hearts`.`heartable_type` = 'Wiki' AND `hearts`.`heartable_id` IN (SELECT `wikis`.`id` FROM `wikis` WHERE (wikis.project_id IN (4)))) OR `hearts`.`heartable_type` = 'Journal' AND `hearts`.`heartable_id` IN (SELECT `journals`.`id` FROM `journals` INNER JOIN `issues` ON `issues`.`id` = `journals`.`journalized_id` INNER JOIN `projects` ON `projects`.`id` = `issues`.`project_id` WHERE (projects.status <> 9 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='issue_tracking')) AND ((journals.private_notes = FALSE OR journals.user_id = 5 OR (projects.status <> 9))) AND `journals`.`journalized_type` = 'Issue' AND `journals`.`journalized_id` IN (SELECT `issues`.`id` FROM `issues` WHERE `issues`.`project_id` = 4))) OR `hearts`.`heartable_type` = 'Issue' AND `hearts`.`heartable_id` IN (SELECT `issues`.`id` FROM `issues` INNER JOIN `projects` ON `projects`.`id` = `issues`.`project_id` WHERE (projects.status <> 9 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='issue_tracking')) AND (issues.project_id IN (4)))) OR `hearts`.`heartable_type` = 'News' AND `hearts`.`heartable_id` IN (SELECT `news`.`id` FROM `news` INNER JOIN `projects` ON `projects`.`id` = `news`.`project_id` WHERE (projects.status <> 9 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='news')) AND (news.project_id IN (4)))) AND `hearts`.`user_id` != 5 GROUP BY `hearts`.`heartable_type`, `hearts`.`heartable_id` ORDER BY `hearts`.`created_at` DESC LIMIT 25 OFFSET 0):

plugins/redmine_hearts/app/controllers/hearts_controller.rb:45:in `map'
plugins/redmine_hearts/app/controllers/hearts_controller.rb:45:in `index'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
plugins/redmine_dmsf/lib/redmine_dmsf/webdav/custom_middleware.rb:68:in `call'
cat-in-136 commented 5 years ago

@zhongw, Thank you for your report. Please write your environment of ruby version, redmine version and DB version?

I guess you use mysql 5.7+. If my understanding is correct, the workaround of this issue is to set ONLY_FULL_GROUP_BY to 0.

cat-in-136 commented 5 years ago

@zhongw , I have successfully reproduced using a docker.io/mysql:8.0 container. I have created a PR #19 for this bug. Could you confirm it?

zhongw commented 5 years ago

sorry for the insufficient info, my DB is mysql 5.7.24, redmine is running under 4.0. The error disappeared after I configured the sqlmode. I do not have an instance of MySQL 8.0, so i am not sure it is an issue with MySQL 8.0 thank you for your help. ^^