aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--History.txt1
-rw-r--r--lib/arel/crud.rb6
-rw-r--r--test/test_select_manager.rb6
3 files changed, 12 insertions, 1 deletions
diff --git a/History.txt b/History.txt
index a5f630b021..9c0d3198a1 100644
--- a/History.txt
+++ b/History.txt
@@ -9,6 +9,7 @@
* Add Arel::SelectManager#limit=
* Add Arel::SelectManager#offset
* Add Arel::SelectManager#offset=
+ * Added Arel::SelectManager#create_insert for building an insert manager.
* Math operations have been added to attributes, thanks to
Vladimir Meremyanin.
diff --git a/lib/arel/crud.rb b/lib/arel/crud.rb
index bedfb8c30c..43805dd464 100644
--- a/lib/arel/crud.rb
+++ b/lib/arel/crud.rb
@@ -32,11 +32,15 @@ switch to `compile_update`
end
def compile_insert values
- im = InsertManager.new @engine
+ im = create_insert
im.insert values
im
end
+ def create_insert
+ InsertManager.new @engine
+ end
+
# FIXME: this method should go away
def insert values
if $VERBOSE
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb
index 410fe38e2a..3eec73a1f0 100644
--- a/test/test_select_manager.rb
+++ b/test/test_select_manager.rb
@@ -483,6 +483,12 @@ module Arel
assert_equal children, clause.children
end
+ it 'should create insert managers' do
+ relation = Arel::SelectManager.new Table.engine
+ insert = relation.create_insert
+ assert_kind_of Arel::InsertManager, insert
+ end
+
it 'should create join nodes' do
relation = Arel::SelectManager.new Table.engine
join = relation.create_join 'foo', 'bar'