activerecord-import 0.26.0 → 0.27.0

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
- SHA256:
3
- metadata.gz: ecfc0672f1042ae828bb3125c0675364d1af8e1b4aefb82af633d3656a8d5fc6
4
- data.tar.gz: 8b03926293827932a61342fded8e5400fbe8261e92817ce32c09eda7fa16860f
2
+ SHA1:
3
+ metadata.gz: 00e3b31f9b8fbe29c0ed8b6a58b6a1afeb0a3f67
4
+ data.tar.gz: b854ffc00c14c4cfc64a67819a367b35941cdb80
5
5
  SHA512:
6
- metadata.gz: 874795a3c02d59b9411ab831ba6257c0c4dab7bad2b478e69451b3d5344652f4d2f906f727189170dc8417ae64a5a2f236a61da1b24a8c1112a7e731a087a7ca
7
- data.tar.gz: 00abfb0263c84d2c687451bd1344ae73935291b8db074388c64220d1d6e5ee9dccc515f62217cc4a61c5912acd1de60d5a57ac7229b3734fa145bfd7936f5b56
6
+ metadata.gz: 164ff30dd1c1f19becb91dd2e7c0d3c9d022489b5065a337743b5eb84a497e58dd6ddaee43a401127cf06c60f3320d4501c962dd91885127b86acea4542315d9
7
+ data.tar.gz: 0dad63cbd8a90ee1f31483796a470088cbd4f35eca9579f707e394500ab6e2ab9524150e49d3a2bee60b79b367c8974855dd5af413c33b326ed4796d0852e118
@@ -1,3 +1,12 @@
1
+ ## Changes in 0.27.0
2
+
3
+ ### New Features
4
+
5
+ * Add "secret" option validate_uniqueness to enable uniqueness
6
+ validators when validating import. This is not a recommended
7
+ approach (See #228), but is being added back in for projects
8
+ that depended on this feature. Thanks to @jkowens via \#554.
9
+
1
10
  ## Changes in 0.26.0
2
11
 
3
12
  ### New Features
@@ -42,7 +42,7 @@ module ActiveRecord::Import #:nodoc:
42
42
 
43
43
  model._validate_callbacks.each do |callback|
44
44
  filter = callback.raw_filter
45
- if filter.is_a?(ActiveRecord::Validations::UniquenessValidator) ||
45
+ if (!@options[:validate_uniqueness] && filter.is_a?(ActiveRecord::Validations::UniquenessValidator)) ||
46
46
  (defined?(ActiveRecord::Validations::PresenceValidator) && filter.is_a?(ActiveRecord::Validations::PresenceValidator) && associations.include?(filter.attributes.first))
47
47
  validate_callbacks.delete(callback)
48
48
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.26.0".freeze
3
+ VERSION = "0.27.0".freeze
4
4
  end
5
5
  end
@@ -210,9 +210,9 @@ describe "#import" do
210
210
  end
211
211
 
212
212
  it "should ignore uniqueness validators" do
213
- Topic.import columns, valid_values, validate: true
213
+ Topic.import columns, valid_values
214
214
  assert_difference "Topic.count", +2 do
215
- Topic.import columns, valid_values, validate: true
215
+ Topic.import columns, valid_values
216
216
  end
217
217
  end
218
218
 
@@ -294,6 +294,15 @@ describe "#import" do
294
294
  end
295
295
  end
296
296
  end
297
+
298
+ context "with uniqueness validators included" do
299
+ it "should not import duplicate records" do
300
+ Topic.import columns, valid_values
301
+ assert_no_difference "Topic.count" do
302
+ Topic.import columns, valid_values, validate_uniqueness: true
303
+ end
304
+ end
305
+ end
297
306
  end
298
307
 
299
308
  context "without :validation option" 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.26.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-05 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.7.7
187
+ rubygems_version: 2.6.11
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Bulk insert extension for ActiveRecord