Commit dcdbc377 authored by Felipe Artur's avatar Felipe Artur

Fix epics search query

Fix epics search query when CTE is enabled
parent bee71dd6
......@@ -55,7 +55,6 @@ class EpicsFinder < IssuableFinder
items = init_collection
items = by_created_at(items)
items = by_updated_at(items)
items = by_search(items)
items = by_author(items)
items = by_timeframe(items)
items = by_state(items)
......@@ -64,6 +63,12 @@ class EpicsFinder < IssuableFinder
items = by_iids(items)
items = starts_with_iid(items)
# This has to be last as we use a CTE as an optimization fence
# for counts by passing the force_cte param and enabling the
# attempt_group_search_optimizations feature flag
# https://www.postgresql.org/docs/current/static/queries-with.html
items = by_search(items)
sort(items)
end
......
......@@ -272,6 +272,21 @@ describe EpicsFinder do
expect { epics(iid_starts_with: '-1') }.to raise_error(ArgumentError)
end
end
context 'when using group cte for search' do
context 'and two labels more search string are present' do
let_it_be(:label1) { create(:label) }
let_it_be(:label2) { create(:label) }
let!(:labeled_epic) { create(:labeled_epic, group: group, title: 'filtered epic', labels: [label1, label2]) }
it 'returns correct epics' do
filtered_epics =
epics(attempt_group_search_optimizations: true, label_name: [label1.title, label2.title], search: 'filtered')
expect(filtered_epics).to contain_exactly(labeled_epic)
end
end
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment