Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a38c93c7
Commit
a38c93c7
authored
Nov 25, 2021
by
Adam Hegyi
Committed by
Mayra Cabrera
Nov 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix disappearing ORDER BY when keyset paginating
parent
0c5be42c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
lib/gitlab/pagination/keyset/iterator.rb
lib/gitlab/pagination/keyset/iterator.rb
+1
-1
lib/gitlab/pagination/keyset/order.rb
lib/gitlab/pagination/keyset/order.rb
+1
-1
spec/requests/api/graphql/packages/package_spec.rb
spec/requests/api/graphql/packages/package_spec.rb
+39
-0
No files found.
lib/gitlab/pagination/keyset/iterator.rb
View file @
a38c93c7
...
...
@@ -9,7 +9,7 @@ module Gitlab
raise
(
UnsupportedScopeOrder
)
unless
success
@cursor
=
cursor
@order
=
Gitlab
::
Pagination
::
Keyset
::
Order
.
extract_keyset_order_object
(
scope
)
@order
=
Gitlab
::
Pagination
::
Keyset
::
Order
.
extract_keyset_order_object
(
@
scope
)
@use_union_optimization
=
in_operator_optimization_options
?
false
:
use_union_optimization
@in_operator_optimization_options
=
in_operator_optimization_options
end
...
...
lib/gitlab/pagination/keyset/order.rb
View file @
a38c93c7
...
...
@@ -155,7 +155,7 @@ module Gitlab
def
apply_cursor_conditions
(
scope
,
values
=
{},
options
=
{
use_union_optimization:
false
,
in_operator_optimization_options:
nil
})
values
||=
{}
transformed_values
=
values
.
with_indifferent_access
scope
=
apply_custom_projections
(
scope
.
dup
)
scope
=
apply_custom_projections
(
scope
)
where_values
=
build_where_values
(
transformed_values
)
...
...
spec/requests/api/graphql/packages/package_spec.rb
View file @
a38c93c7
...
...
@@ -96,4 +96,43 @@ RSpec.describe 'package details' do
expect
(
graphql_data_at
(
:b
)).
to
be
(
nil
)
end
end
context
'when loading pipelines ordered by ID DESC'
do
let
(
:pipelines
)
{
create_list
(
:ci_pipeline
,
6
,
project:
project
)
}
before
do
composer_package
.
pipelines
=
pipelines
composer_package
.
save!
end
def
run_query
(
args
)
pipelines_nodes
=
<<~
QUERY
nodes {
id
}
pageInfo {
endCursor
}
QUERY
query
=
graphql_query_for
(
:package
,
{
id:
package_global_id
},
query_graphql_field
(
"pipelines"
,
args
,
pipelines_nodes
))
post_graphql
(
query
,
current_user:
user
)
end
it
'loads the second page correctly'
do
run_query
({
first:
2
})
cursor
=
graphql_data
.
dig
(
'package'
,
'pipelines'
,
'pageInfo'
,
'endCursor'
)
run_query
({
first:
2
,
after:
cursor
})
expected_pipeline_ids
=
pipelines
.
sort_by
(
&
:id
)
.
reverse
[
2
..
3
]
# second page
.
map
{
|
pipeline
|
pipeline
.
to_gid
.
to_s
}
pipeline_ids
=
graphql_data
.
dig
(
'package'
,
'pipelines'
,
'nodes'
).
pluck
(
'id'
)
expect
(
pipeline_ids
).
to
eq
(
expected_pipeline_ids
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment