Commit 7769878f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'ab/keyset-ambig-bug' into 'master'

Fully qualify id columns for keyset pagination

See merge request gitlab-org/gitlab!29026
parents d009db9e aee025ad
......@@ -142,8 +142,8 @@ class ProjectsFinder < UnionFinder
# rubocop: disable CodeReuse/ActiveRecord
def by_ids(items)
items = items.where(id: project_ids_relation) if project_ids_relation
items = items.where('id > ?', params[:id_after]) if params[:id_after]
items = items.where('id < ?', params[:id_before]) if params[:id_before]
items = items.where('projects.id > ?', params[:id_after]) if params[:id_after]
items = items.where('projects.id < ?', params[:id_before]) if params[:id_before]
items
end
# rubocop: enable CodeReuse/ActiveRecord
......
---
title: Fully qualify id columns for keyset pagination (Projects API)
merge_request: 29026
author:
type: fixed
......@@ -85,6 +85,24 @@ describe ProjectsFinder, :do_not_mock_admin_mode do
end
end
describe 'regression: Combination of id_before/id_after and joins requires fully qualified column names' do
context 'only returns projects with a project id less than given and matching search' do
subject { finder.execute.joins(:route) }
let(:params) { { id_before: public_project.id }}
it { is_expected.to eq([internal_project]) }
end
context 'only returns projects with a project id greater than given and matching search' do
subject { finder.execute.joins(:route) }
let(:params) { { id_after: internal_project.id }}
it { is_expected.to eq([public_project]) }
end
end
describe 'filter by visibility_level' do
before do
private_project.add_maintainer(user)
......
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