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
6a605c08
Commit
6a605c08
authored
Jul 06, 2020
by
Andreas Brandl
Committed by
Adam Hegyi
Jul 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove check for availability of PG upsert
With >= PG11, this is not necessary anymore
parent
faca8aaf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
31 deletions
+7
-31
lib/gitlab/database.rb
lib/gitlab/database.rb
+1
-7
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+6
-24
No files found.
lib/gitlab/database.rb
View file @
6a605c08
...
...
@@ -107,10 +107,6 @@ module Gitlab
version
.
to_f
>=
MINIMUM_POSTGRES_VERSION
end
def
self
.
upsert_supported?
version
.
to_f
>=
9.5
end
def
self
.
check_postgres_version_and_print_warning
return
if
Gitlab
::
Database
.
postgresql_minimum_supported_version?
return
if
Gitlab
::
Runtime
.
rails_runner?
...
...
@@ -221,9 +217,7 @@ module Gitlab
VALUES
#{
tuples
.
map
{
|
tuple
|
"(
#{
tuple
.
join
(
', '
)
}
)"
}
.join(', ')}
EOF
if
upsert_supported?
&&
on_conflict
==
:do_nothing
sql
=
"
#{
sql
}
ON CONFLICT DO NOTHING"
end
sql
=
"
#{
sql
}
ON CONFLICT DO NOTHING"
if
on_conflict
==
:do_nothing
sql
=
"
#{
sql
}
RETURNING id"
if
return_ids
...
...
spec/lib/gitlab/database_spec.rb
View file @
6a605c08
...
...
@@ -283,7 +283,6 @@ RSpec.describe Gitlab::Database do
describe
'.bulk_insert'
do
before
do
allow
(
described_class
).
to
receive
(
:connection
).
and_return
(
connection
)
allow
(
described_class
).
to
receive
(
:version
).
and_return
(
version
)
allow
(
connection
).
to
receive
(
:quote_column_name
,
&
:itself
)
allow
(
connection
).
to
receive
(
:quote
,
&
:itself
)
allow
(
connection
).
to
receive
(
:execute
)
...
...
@@ -298,8 +297,6 @@ RSpec.describe Gitlab::Database do
]
end
let_it_be
(
:version
)
{
9.6
}
it
'does nothing with empty rows'
do
expect
(
connection
).
not_to
receive
(
:execute
)
...
...
@@ -366,7 +363,6 @@ RSpec.describe Gitlab::Database do
expect
(
ids
).
to
eq
([
10
])
end
context
'with version >= 9.5'
do
it
'allows setting the upsert to do nothing'
do
expect
(
connection
)
.
to
receive
(
:execute
)
...
...
@@ -376,20 +372,6 @@ RSpec.describe Gitlab::Database do
.
bulk_insert
(
'test'
,
[{
number:
10
}],
on_conflict: :do_nothing
)
end
end
context
'with version < 9.5'
do
let
(
:version
)
{
9.4
}
it
'refuses setting the upsert'
do
expect
(
connection
)
.
not_to
receive
(
:execute
)
.
with
(
/ON CONFLICT/
)
described_class
.
bulk_insert
(
'test'
,
[{
number:
10
}],
on_conflict: :do_nothing
)
end
end
end
end
describe
'.create_connection_pool'
do
...
...
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