activerecord-import 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f09939f85ac5eea9961edb723ad60f0f44d4a8
|
4
|
+
data.tar.gz: d50f35bc63818c96ffa772d157189d96a738784b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f4cf1a65474d658e5091b60b12756f70c6fe1af84d0b2477777f27cc76d137eb1bc7064ab8d33d548c0c8de01df494ec0fdddf73d7e55416fc772750bb9899a
|
7
|
+
data.tar.gz: 0b3a592bdbe01be8dd244f52643875825b2c52d8a8ec283f9825cf17012feddb394f131aa9a0722cdf89d9a8a6835ddff0a219b86e4d4049b70f8aca1f808b50
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## Changes in 0.16.1
|
2
|
+
|
3
|
+
### Fixes
|
4
|
+
|
5
|
+
* Fixes issue with missing error messages on failed instances when
|
6
|
+
importing using arrays of columns and values. Thanks to @Fivell via \#332
|
7
|
+
* Update so SQLite only return ids if table has a primary key field via \#333
|
8
|
+
|
9
|
+
|
1
10
|
## Changes in 0.16.0
|
2
11
|
|
3
12
|
### New Features
|
@@ -35,8 +35,10 @@ module ActiveRecord::Import::SQLite3Adapter
|
|
35
35
|
number_of_inserts += 1
|
36
36
|
sql2insert = base_sql + value_set.join( ',' ) + post_sql
|
37
37
|
last_insert_id = insert( sql2insert, *args )
|
38
|
-
|
39
|
-
|
38
|
+
if last_insert_id > 0
|
39
|
+
first_insert_id = last_insert_id - affected_rows + 1
|
40
|
+
ids.concat((first_insert_id..last_insert_id).to_a)
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -476,7 +476,9 @@ class ActiveRecord::Base
|
|
476
476
|
next if model.valid?(options[:validate_with_context])
|
477
477
|
raise(ActiveRecord::RecordInvalid, model) if options[:raise_error]
|
478
478
|
array_of_attributes[i] = nil
|
479
|
-
|
479
|
+
failure = model.dup
|
480
|
+
failure.errors.send(:initialize_dup, model.errors)
|
481
|
+
failed_instances << failure
|
480
482
|
end
|
481
483
|
end
|
482
484
|
|
data/test/import_test.rb
CHANGED
@@ -121,7 +121,11 @@ describe "#import" do
|
|
121
121
|
it "should report the failed instances" do
|
122
122
|
results = Topic.import columns, invalid_values, validate: true
|
123
123
|
assert_equal invalid_values.size, results.failed_instances.size
|
124
|
-
results.failed_instances.
|
124
|
+
assert_not_equal results.failed_instances.first, results.failed_instances.last
|
125
|
+
results.failed_instances.each do |e|
|
126
|
+
assert_kind_of Topic, e
|
127
|
+
assert_equal e.errors.count, 1
|
128
|
+
end
|
125
129
|
end
|
126
130
|
|
127
131
|
it "should set ids in valid models if adapter supports setting primary key of imported objects" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|