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 <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
Jacob Fugal 2013-04-02 16:05:19 -06:00
parent 9bb10561cd
commit d67fe68102
1 changed files with 5 additions and 3 deletions

View File

@ -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)