aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-19 10:27:39 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-19 10:27:39 -0300
commite295d61d6d4f13aee08c895751277531edb39993 (patch)
treefce2b9df88a3d03978d603fb9ad1b62da2272009
parent61b2d2242208ac9997ff6b73d92d3fc6c26f2171 (diff)
parent97bfc5b7328e1d2bc54b4592c931a2dcee9b7926 (diff)
downloadrails-e295d61d6d4f13aee08c895751277531edb39993.tar.gz
rails-e295d61d6d4f13aee08c895751277531edb39993.tar.bz2
rails-e295d61d6d4f13aee08c895751277531edb39993.zip
Merge pull request #271 from jordansexton/patch-2
Added update and delete convenience methods
-rw-r--r--lib/arel/table.rb8
-rw-r--r--test/test_table.rb16
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb
index 3866637bd2..545e73e3ae 100644
--- a/lib/arel/table.rb
+++ b/lib/arel/table.rb
@@ -108,6 +108,14 @@ primary_key (#{caller.first}) is deprecated and will be removed in Arel 4.0.0
InsertManager.new(@engine)
end
+ def update_manager
+ UpdateManager.new(@engine)
+ end
+
+ def delete_manager
+ DeleteManager.new(@engine)
+ end
+
def hash
# Perf note: aliases, table alias and engine is excluded from the hash
# aliases can have a loop back to this table breaking hashes in parent
diff --git a/test/test_table.rb b/test/test_table.rb
index 286ad10167..14256475ec 100644
--- a/test/test_table.rb
+++ b/test/test_table.rb
@@ -67,6 +67,22 @@ module Arel
end
end
+ describe 'update_manager' do
+ it 'should return an update manager' do
+ um = @relation.update_manager
+ assert_kind_of Arel::UpdateManager, um
+ assert_equal um.engine, @relation.engine
+ end
+ end
+
+ describe 'delete_manager' do
+ it 'should return a delete manager' do
+ dm = @relation.delete_manager
+ assert_kind_of Arel::DeleteManager, dm
+ assert_equal dm.engine, @relation.engine
+ end
+ end
+
describe 'having' do
it 'adds a having clause' do
mgr = @relation.having @relation[:id].eq(10)