Project

General

Profile

Actions

Bug #21082

closed

Combination of owner search with generic search term ends up with sql issues

Added by Ivan Necas about 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Reproducer:

1. search for owner.id = current_user AND ITSBROKEN
2. exception is given:

PG::DuplicateAlias: ERROR:  table name "foreman_tasks_locks_owner" specified more than once
: SELECT  DISTINCT "foreman_tasks_tasks".* FROM "foreman_tasks_tasks" INNER JOIN "foreman_tasks_locks" ON "foreman_tasks_locks"."task_id" = "foreman_tasks_tasks"."id" INNER JOIN foreman_tasks_locks AS foreman_tasks_locks_owner
                 ON (foreman_tasks_locks_owner.task_id = foreman_tasks_tasks.id AND
                     foreman_tasks_locks_owner.resource_type = 'User' AND
                     foreman_tasks_locks_owner.name = 'task_owner') INNER JOIN foreman_tasks_locks AS foreman_tasks_locks_owner
                 ON (foreman_tasks_locks_owner.task_id = foreman_tasks_tasks.id AND
                     foreman_tasks_locks_owner.resource_type = 'User' AND
                     foreman_tasks_locks_owner.name = 'task_owner')
        INNER JOIN users as users
                   ON (users.id = foreman_tasks_locks_owner.resource_id) WHERE (((foreman_tasks_locks_owner.resource_id = 3) AND ("foreman_tasks_tasks"."id" ILIKE '%ITISBROKEN%' OR "foreman_tasks_tasks"."label" ILIKE '%ITISBROKEN%' OR "foreman_tasks_tasks"."state" ILIKE '%ITISBROKEN%' OR "foreman_tasks_tasks"."result" ILIKE '%ITISBROKEN%' OR "foreman_tasks_tasks"."parent_task_id" ILIKE '%ITISBROKEN%' OR foreman_tasks_locks."resource_type" ILIKE 'ITISBROKEN' OR users.login ILIKE 'ITISBROKEN' or users.firstname ILIKE 'ITISBROKEN'  OR users.login ILIKE 'ITISBROKEN' or users.firstname ILIKE 'ITISBROKEN' )))  ORDER BY "foreman_tasks_tasks"."started_at" DESC NULLS LAST  LIMIT 20 OFFSET 0

Expected:

No exception


Related issues 1 (0 open1 closed)

Related to foreman-tasks - Refactor #21083: Use explicit relation for task -> user associationClosedAdam RuzickaActions
Actions

Also available in: Atom PDF