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: 64717eaa9cb0c49761ad29e6aa358c87e96b7166
4
- data.tar.gz: 879ac9c11ee4a9a62988c97608ad195a1052893d
3
+ metadata.gz: 90f09939f85ac5eea9961edb723ad60f0f44d4a8
4
+ data.tar.gz: d50f35bc63818c96ffa772d157189d96a738784b
5
5
  SHA512:
6
- metadata.gz: 7e06cfe24bc207291c4a4c8737f8c3d6309218ccde2ca3246089f45d7f36c85f6fa7a63abe5758934dd6c9e939422c40395880b7ba950e10db7b96fa38b071af
7
- data.tar.gz: 6ce0fc279753ab340269eefa2d64be18c40d2bed279f3cda27ba4057cb428582a207c5637da5a7c5222cffa77d2a43a0030578c87ebe05f76c81ad098da3fa21
6
+ metadata.gz: 4f4cf1a65474d658e5091b60b12756f70c6fe1af84d0b2477777f27cc76d137eb1bc7064ab8d33d548c0c8de01df494ec0fdddf73d7e55416fc772750bb9899a
7
+ data.tar.gz: 0b3a592bdbe01be8dd244f52643875825b2c52d8a8ec283f9825cf17012feddb394f131aa9a0722cdf89d9a8a6835ddff0a219b86e4d4049b70f8aca1f808b50
@@ -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
- first_insert_id = last_insert_id - affected_rows + 1
39
- ids.concat((first_insert_id..last_insert_id).to_a)
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
- failed_instances << model.dup
479
+ failure = model.dup
480
+ failure.errors.send(:initialize_dup, model.errors)
481
+ failed_instances << failure
480
482
  end
481
483
  end
482
484
 
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.16.0".freeze
3
+ VERSION = "0.16.1".freeze
4
4
  end
5
5
  end
@@ -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.each { |e| assert_kind_of Topic, e }
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord