diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-13 13:21:18 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-13 13:21:18 -0800 |
commit | 79e6c7d2301d452c721d0b806071b0ebe2255eca (patch) | |
tree | 3dc67c59614f80db0d758fb29dde015e9d85e456 /activerecord | |
parent | 6ed6e4f9df7c08cbf053501346beb4b0fb42b348 (diff) | |
download | rails-79e6c7d2301d452c721d0b806071b0ebe2255eca.tar.gz rails-79e6c7d2301d452c721d0b806071b0ebe2255eca.tar.bz2 rails-79e6c7d2301d452c721d0b806071b0ebe2255eca.zip |
stop delegating inserts to ARel, use the INSERT SQL ourselves
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 14 |
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 |