Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stop delegating inserts to ARel, use the INSERT SQL ourselves

  • Loading branch information...
commit 63480d234df401d678bb7c5a8cef662e3222d841 1 parent a1ca1e8
@tenderlove tenderlove authored vijaydev committed
Showing with 13 additions and 1 deletion.
  1. +13 −1 activerecord/lib/active_record/relation.rb
View
14 activerecord/lib/active_record/relation.rb
@@ -11,7 +11,6 @@ class Relation
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 @@ def initialize(klass, table)
@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
Please sign in to comment.
Something went wrong with that request. Please try again.