Skip to content

Commit

Permalink
FIX: prevents column reference "id" is ambiguous
Browse files Browse the repository at this point in the history
I noticed this error in production log but couldn't reproduce it locally. I suspect it's related to a specific combination of plugins.

Ensuring all column names are not ambiguous in this query shouldn't hurt and should fix the problem.
  • Loading branch information
jjaffeux committed Aug 25, 2024
1 parent 5eab6bb commit 81fd3b7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/discourse_assign/group_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ module GroupExtension
scope :assignable,
->(user) do
where(
"assignable_level in (:levels) OR
"groups.assignable_level in (:levels) OR
(
assignable_level = #{Group::ALIAS_LEVELS[:members_mods_and_admins]} AND id in (
SELECT group_id FROM group_users WHERE user_id = :user_id)
groups.assignable_level = #{Group::ALIAS_LEVELS[:members_mods_and_admins]} AND groups.id in (
SELECT group_id FROM group_users AS gu WHERE gu.user_id = :user_id)
) OR (
assignable_level = #{Group::ALIAS_LEVELS[:owners_mods_and_admins]} AND id in (
SELECT group_id FROM group_users WHERE user_id = :user_id AND owner IS TRUE)
groups.assignable_level = #{Group::ALIAS_LEVELS[:owners_mods_and_admins]} AND groups.id in (
SELECT group_id FROM group_users as gu WHERE gu.user_id = :user_id AND gu.owner IS TRUE)
)",
levels: alias_levels(user),
user_id: user&.id,
Expand Down

0 comments on commit 81fd3b7

Please sign in to comment.