activerecord-import 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ namespace :display do
|
|
36
36
|
end
|
37
37
|
task :default => ["display:notice"]
|
38
38
|
|
39
|
-
ADAPTERS = %w(mysql mysql2 jdbcmysql postgresql sqlite3)
|
39
|
+
ADAPTERS = %w(mysql mysql2 jdbcmysql postgresql sqlite3 seamless_database_pool)
|
40
40
|
ADAPTERS.each do |adapter|
|
41
41
|
namespace :test do
|
42
42
|
desc "Runs #{adapter} database tests."
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.11
|
@@ -2,5 +2,5 @@ require "active_record/connection_adapters/mysql_adapter"
|
|
2
2
|
require "activerecord-import/adapters/mysql_adapter"
|
3
3
|
|
4
4
|
class ActiveRecord::ConnectionAdapters::MysqlAdapter
|
5
|
-
include ActiveRecord::Import::MysqlAdapter
|
5
|
+
include ActiveRecord::Import::MysqlAdapter
|
6
6
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require "seamless_database_pool"
|
2
|
+
require "active_record/connection_adapters/seamless_database_pool_adapter"
|
3
|
+
require "activerecord-import/adapters/mysql_adapter"
|
4
|
+
|
5
|
+
class ActiveRecord::ConnectionAdapters::SeamlessDatabasePoolAdapter
|
6
|
+
include ActiveRecord::Import::MysqlAdapter
|
7
|
+
end
|
@@ -17,6 +17,12 @@ module ActiveRecord::Import #:nodoc:
|
|
17
17
|
true
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
class MissingColumnError < StandardError
|
22
|
+
def initialize(name, index)
|
23
|
+
super "Missing column for value <#{name}> at index #{index}"
|
24
|
+
end
|
25
|
+
end
|
20
26
|
end
|
21
27
|
|
22
28
|
class ActiveRecord::Base
|
@@ -254,8 +260,12 @@ class ActiveRecord::Base
|
|
254
260
|
end
|
255
261
|
end
|
256
262
|
array_of_attributes.compact!
|
257
|
-
|
258
|
-
num_inserts = array_of_attributes.empty?
|
263
|
+
|
264
|
+
num_inserts = if array_of_attributes.empty? || options[:all_or_none] && failed_instances.any?
|
265
|
+
0
|
266
|
+
else
|
267
|
+
import_without_validations_or_callbacks( column_names, array_of_attributes, options )
|
268
|
+
end
|
259
269
|
ActiveRecord::Import::Result.new(failed_instances, num_inserts)
|
260
270
|
end
|
261
271
|
|
@@ -266,7 +276,13 @@ class ActiveRecord::Base
|
|
266
276
|
# information on +column_names+, +array_of_attributes_ and
|
267
277
|
# +options+.
|
268
278
|
def import_without_validations_or_callbacks( column_names, array_of_attributes, options={} )
|
269
|
-
columns = column_names.map
|
279
|
+
columns = column_names.each_with_index.map do |name, i|
|
280
|
+
column = columns_hash[name.to_s]
|
281
|
+
|
282
|
+
raise ActiveRecord::Import::MissingColumnError.new(name.to_s, i) if column.nil?
|
283
|
+
|
284
|
+
column
|
285
|
+
end
|
270
286
|
|
271
287
|
columns_sql = "(#{column_names.map{|name| connection.quote_column_name(name) }.join(',')})"
|
272
288
|
insert_sql = "INSERT #{options[:ignore] ? 'IGNORE ':''}INTO #{quoted_table_name} #{columns_sql} VALUES "
|
@@ -297,6 +313,7 @@ class ActiveRecord::Base
|
|
297
313
|
array_of_attributes.map do |arr|
|
298
314
|
my_values = arr.each_with_index.map do |val,j|
|
299
315
|
column = columns[j]
|
316
|
+
|
300
317
|
if val.nil? && !sequence_name.blank? && column.name == primary_key
|
301
318
|
connection.next_value_for_sequence(sequence_name)
|
302
319
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/activerecord-import/active_record/adapters/mysql2_adapter.rb
|
93
93
|
- lib/activerecord-import/active_record/adapters/mysql_adapter.rb
|
94
94
|
- lib/activerecord-import/active_record/adapters/postgresql_adapter.rb
|
95
|
+
- lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb
|
95
96
|
- lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb
|
96
97
|
- lib/activerecord-import/adapters/abstract_adapter.rb
|
97
98
|
- lib/activerecord-import/adapters/mysql_adapter.rb
|
@@ -118,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
119
|
version: '0'
|
119
120
|
segments:
|
120
121
|
- 0
|
121
|
-
hash:
|
122
|
+
hash: 4132545664813996444
|
122
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
124
|
none: false
|
124
125
|
requirements:
|