aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-12-13 13:21:18 -0800
committerVijay Dev <vijaydev.cse@gmail.com>2010-12-16 01:49:29 +0530
commit63480d234df401d678bb7c5a8cef662e3222d841 (patch)
treeb3e6bcae0663f84fce0a990dc452eaf15e6e1d8e /activerecord/lib/active_record
parenta1ca1e85a9ccefd72db4dc700a894c5bd7db53de (diff)
downloadrails-63480d234df401d678bb7c5a8cef662e3222d841.tar.gz
rails-63480d234df401d678bb7c5a8cef662e3222d841.tar.bz2
rails-63480d234df401d678bb7c5a8cef662e3222d841.zip
stop delegating inserts to ARel, use the INSERT SQL ourselves
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 3009bb70c1..7ecba1c43a 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -11,7 +11,6 @@ module ActiveRecord
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches
delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to => :to_a
- delegate :insert, :to => :arel
attr_reader :table, :klass, :loaded
attr_accessor :extensions
@@ -28,6 +27,19 @@ module ActiveRecord
@extensions = []
end
+ def insert(values)
+ im = arel.compile_insert values
+ im.into @table
+ primary_key_name = @klass.primary_key
+ primary_key_value = Hash === values ? values[primary_key_name] : nil
+
+ @klass.connection.insert(
+ im.to_sql,
+ 'SQL',
+ primary_key_name,
+ primary_key_value)
+ end
+
def new(*args, &block)
scoping { @klass.new(*args, &block) }
end