summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-05-23 00:25:26 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-05-23 00:25:26 +0800
commitb3095251c4bd620e85cb22f9fc8b8c75bcbed4d4 (patch)
tree36cd4121006a3cf4a3c0832cc3af32bb2da45c1d
parenta4407e75d374f65d8638d40eadbd0ec8c32cd6f6 (diff)
downloadgitlab-ce-test-update_column_in_batches-with-sql-mysql.tar.gz
Make sure that Arel.sql would work for update_column_in_batchestest-update_column_in_batches-with-sql-mysql
-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