Merge pull request #1824 from riking/patch-2

Fix group matching SQL query
This commit is contained in:
Sam 2014-02-06 08:07:13 +11:00
commit 447816fe39

View File

@ -123,9 +123,9 @@ class Group < ActiveRecord::Base
ALIAS_LEVELS[:members_mods_and_admins]]
end
Group.where("name LIKE :term_like AND (" +
Group.where("name ILIKE :term_like AND (" +
" alias_level in (:levels)" +
" OR (alias_level = #{ALIAS_LEVELS[:everyone]} AND id in (" +
" OR (alias_level = #{ALIAS_LEVELS[:members_mods_and_admins]} AND id in (" +
"SELECT group_id FROM group_users WHERE user_id= :user_id)" +
")" +
")", term_like: "#{name.downcase}%", levels: levels, user_id: current_user.id)