diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-05-22 19:25:26 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-05-22 19:25:26 +0300 |
commit | b3095251c4bd620e85cb22f9fc8b8c75bcbed4d4 (patch) | |
tree | 36cd4121006a3cf4a3c0832cc3af32bb2da45c1d /spec/lib/gitlab/database | |
parent | a4407e75d374f65d8638d40eadbd0ec8c32cd6f6 (diff) |
Make sure that Arel.sql would work for update_column_in_batches
Diffstat (limited to 'spec/lib/gitlab/database')
-rw-r--r-- | spec/lib/gitlab/database/migration_helpers_spec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index dfa3ae9142e..bd5ac6142be 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -247,6 +247,14 @@ describe Gitlab::Database::MigrationHelpers, lib: true do expect(Project.where(archived: true).count).to eq(1) end end + + context 'when the value is Arel.sql (Arel::Nodes::SqlLiteral)' do + it 'updates the value as a SQL expression' do + model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1')) + + expect(Project.sum(:star_count)).to eq(2 * Project.count) + end + end end describe '#add_column_with_default' do |