activerecord_save_many 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -87,7 +87,8 @@ module ActiveRecord
87
87
  columns.map{|col| obj[col]}
88
88
  end
89
89
 
90
- sql = connection.save_many_sql(table_name,
90
+ sql = connection.save_many_sql(self,
91
+ table_name,
91
92
  columns,
92
93
  rows,
93
94
  { :ignore=>options[:ignore],
@@ -101,12 +102,12 @@ module ActiveRecord
101
102
  end
102
103
 
103
104
  module MySQL
104
- def save_many_sql(table_name, columns, rows, options)
105
+ def save_many_sql(klass, table_name, columns, rows, options)
105
106
  Functions::check_options(SQL_OPTIONS_KEYS, options)
106
107
 
107
108
  sql = ["insert", ("delayed" if options[:async]), ("ignore" if options[:ignore])].compact.join(' ') +
108
109
  " into #{table_name} (#{columns.join(',')}) values " +
109
- rows.map{|vals| "(" + vals.map{|v| quote_value(v)}.join(",") +")"}.join(",") +
110
+ rows.map{|vals| "(" + vals.map{|v| klass.quote_value(v)}.join(",") +")"}.join(",") +
110
111
  (" on duplicate key update "+columns.map{|c| options[:updates][c] || "#{c}=values(#{c})"}.join(",") if options[:update]).to_s
111
112
  end
112
113
  end
@@ -106,8 +106,8 @@ module ActiveRecord
106
106
  stub(k).table_name{tablename}
107
107
  cns = column_names.map{|cn| col=Object.new ; stub(col).name{cn} ; col}
108
108
  stub(k).columns{cns}
109
+ stub(k).quote_value{|v| "'#{v}'"}
109
110
  connection = ActiveRecord::ConnectionAdapters::MysqlAdapter.new
110
- stub(connection).quote_value{|v| "'#{v}'"}
111
111
  stub(connection).execute_raw{|sql|
112
112
  sql.should == match_sql
113
113
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_save_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mccraigmccraig