summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-05-23 10:37:22 +0000
committerRémy Coutable <remy@rymai.me>2017-05-23 10:37:22 +0000
commit12e77890c29c0451ac7a1a59727df4d56bc9741b (patch)
tree725d708850c232adb2a58417eea860a1886893a0
parent35ab669a957dd63a5c662ba909f368380e3a60c7 (diff)
parentb3095251c4bd620e85cb22f9fc8b8c75bcbed4d4 (diff)
downloadgitlab-ce-12e77890c29c0451ac7a1a59727df4d56bc9741b.tar.gz
Merge branch 'test-update_column_in_batches-with-sql-mysql' into 'master'
Make sure that Arel.sql would work for update_column_in_batches See merge request !11610
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb8
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