From d67fe681022559f5ea417d12d80a21bd4d739841 Mon Sep 17 00:00:00 2001 From: Jacob Fugal Date: Tue, 2 Apr 2013 16:05:19 -0600 Subject: [PATCH] fix messageable_users query for mysql fixes CNVS-5067 test-plan: - use mysql database - create an account admin - create a course with a teacher in that admin's account - as the account admin - go to the conversation inbox - open the recipient browser for a new conversation - search for the teacher - should find the teacher without any server errors Change-Id: Iff383bb8eff62dd1caf27f57b3300675a1ca1dbb Reviewed-on: https://gerrit.instructure.com/19306 Reviewed-by: Cody Cutrer Tested-by: Jenkins QA-Review: Clare Hetherington Product-Review: Jacob Fugal --- lib/messageable_user/calculator.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/messageable_user/calculator.rb b/lib/messageable_user/calculator.rb index 75d1680bb83..fa3be0d5b4d 100644 --- a/lib/messageable_user/calculator.rb +++ b/lib/messageable_user/calculator.rb @@ -658,14 +658,16 @@ class MessageableUser # in the account (user and account from user_account_associations in the # outer query). used to fake a common "course" context with that enrollment # type in users found via the account roster. + # + # NOTE: the conditions on user_account_associations needs to be a where + # condition vs. an inner join on condition to make mysql happy. HIGHEST_ENROLLMENT_SQL = <<-SQL (SELECT enrollments.type FROM enrollments INNER JOIN courses ON courses.id=enrollments.course_id - INNER JOIN course_account_associations ON - course_account_associations.course_id=courses.id AND - course_account_associations.account_id=user_account_associations.account_id + INNER JOIN course_account_associations ON course_account_associations.course_id=courses.id WHERE enrollments.user_id=user_account_associations.user_id + AND course_account_associations.account_id=user_account_associations.account_id AND #{enrollment_conditions(:include_concluded => false)} ORDER BY #{Enrollment.type_rank_sql} LIMIT 1)