Fix ambiguous namespace_id in query
What does this MR do and why?
Fix ambiguous namespace_id in query
When using in_namespaces_with_cte the query can become ambiguous if there are other namespace_id's joined.
Changelog: fixed
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
For example, joining the work_item_type didn't work since it also has a namespace_id
column.
ctiveRecord::StatementInvalid: PG::AmbiguousColumn: ERROR: column reference "namespace_id" is ambiguous
LINE 1: ...types"."id" = "issues"."work_item_type_id" WHERE (namespace_...
Before
::WorkItems::WorkItemsFinder.new(User.first, group_id: Group.first.id).execute.with_work_item_type.first # => error
After
::WorkItems::WorkItemsFinder.new(User.first, group_id: Group.first.id).execute.with_work_item_type.first