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
ac515aa1
Commit
ac515aa1
authored
Mar 12, 2020
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder exported relations by primary_key
parent
64cedf39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
changelogs/unreleased/georgekoltsov-fix-relations-order-on-export.yml
...nreleased/georgekoltsov-fix-relations-order-on-export.yml
+5
-0
lib/gitlab/import_export/fast_hash_serializer.rb
lib/gitlab/import_export/fast_hash_serializer.rb
+6
-0
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
+10
-0
No files found.
changelogs/unreleased/georgekoltsov-fix-relations-order-on-export.yml
0 → 100644
View file @
ac515aa1
---
title
:
Reorder exported relations by primary_key when using Project Export
merge_request
:
27117
author
:
type
:
fixed
lib/gitlab/import_export/fast_hash_serializer.rb
View file @
ac515aa1
...
...
@@ -136,6 +136,12 @@ module Gitlab
data
=
[]
record
.
in_batches
(
of:
@batch_size
)
do
|
batch
|
# rubocop:disable Cop/InBatches
# order each batch by it's primary key to ensure
# consistent and predictable ordering of each exported relation
# as additional `WHERE` clauses can impact the order in which data is being
# returned by database when no `ORDER` is specified
batch
=
batch
.
reorder
(
batch
.
klass
.
primary_key
)
if
Feature
.
enabled?
(
:export_fast_serialize_with_raw_json
,
default_enabled:
true
)
data
.
append
(
JSONBatchRelation
.
new
(
batch
,
options
,
preloads
[
key
]).
tap
(
&
:raw_json
))
else
...
...
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
View file @
ac515aa1
...
...
@@ -215,6 +215,14 @@ describe Gitlab::ImportExport::FastHashSerializer do
expect
(
subject
[
'boards'
].
first
[
'lists'
]).
not_to
be_empty
end
context
'relation ordering'
do
it
'orders exported pipelines by primary key'
do
expected_order
=
project
.
ci_pipelines
.
reorder
(
:id
).
ids
expect
(
subject
[
'ci_pipelines'
].
pluck
(
'id'
)).
to
eq
(
expected_order
)
end
end
def
setup_project
release
=
create
(
:release
)
group
=
create
(
:group
)
...
...
@@ -246,6 +254,8 @@ describe Gitlab::ImportExport::FastHashSerializer do
ci_build
.
pipeline
.
update
(
project:
project
)
create
(
:commit_status
,
project:
project
,
pipeline:
ci_build
.
pipeline
)
create_list
(
:ci_pipeline
,
5
,
:success
,
project:
project
)
create
(
:milestone
,
project:
project
)
create
(
:discussion_note
,
noteable:
issue
,
project:
project
)
create
(
:note
,
noteable:
merge_request
,
project:
project
)
...
...
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