diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 07:53:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 07:53:40 +0000 |
commit | cfc792b9ca064990e6540cb742e80529ea669a81 (patch) | |
tree | 147cd4256319990cebbc02fe8e4fbbbe06f5720a /spec/lib/gitlab/database_spec.rb | |
parent | 93c6764dacd4c605027ef1cd367d3aebe420b223 (diff) | |
download | gitlab-ce-cfc792b9ca064990e6540cb742e80529ea669a81.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/database_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 15fb1503529..a033316a6d9 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -228,6 +228,7 @@ 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) @@ -242,6 +243,8 @@ describe Gitlab::Database do ] end + let_it_be(:version) { 9.6 } + it 'does nothing with empty rows' do expect(connection).not_to receive(:execute) @@ -307,6 +310,29 @@ 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) + .with(/ON CONFLICT DO NOTHING/) + + described_class + .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 |