Коммит 178c80a5 создал по автору Robert Speicher's avatar Robert Speicher
Просмотр файлов

Merge branch 'fix-activerecord-join-stupidity' into 'master'

Ignore eager loading in Project.search UNION

This fixes issues such as filtering groups by names on pages such as
https://gitlab.com/dashboard/groups.

See merge request !3229
владельцы 09494ff4 c7427602
......@@ -286,7 +286,14 @@ def search(query)
or(ptable[:description].matches(pattern))
)
# We explicitly remove any eager loading clauses as they're:
#
# 1. Not needed by this query
# 2. Combined with .joins(:namespace) lead to all columns from the
# projects & namespaces tables being selected, leading to a SQL error
# due to the columns of all UNION'd queries no longer being the same.
namespaces = select(:id).
except(:includes).
joins(:namespace).
where(ntable[:name].matches(pattern))
......
......@@ -634,6 +634,12 @@
it 'returns projects with a matching namespace name regardless of the casing' do
expect(described_class.search(project.namespace.name.upcase)).to eq([project])
end
it 'returns projects when eager loading namespaces' do
relation = described_class.all.includes(:namespace)
expect(relation.search(project.namespace.name)).to eq([project])
end
end
describe '#rename_repo' do
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать