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 +5 -5
- data/CHANGELOG.md +9 -0
- data/lib/activerecord-import/import.rb +1 -1
- data/lib/activerecord-import/version.rb +1 -1
- data/test/import_test.rb +11 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 00e3b31f9b8fbe29c0ed8b6a58b6a1afeb0a3f67
|
4
|
+
data.tar.gz: b854ffc00c14c4cfc64a67819a367b35941cdb80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 164ff30dd1c1f19becb91dd2e7c0d3c9d022489b5065a337743b5eb84a497e58dd6ddaee43a401127cf06c60f3320d4501c962dd91885127b86acea4542315d9
|
7
|
+
data.tar.gz: 0dad63cbd8a90ee1f31483796a470088cbd4f35eca9579f707e394500ab6e2ab9524150e49d3a2bee60b79b367c8974855dd5af413c33b326ed4796d0852e118
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/test/import_test.rb
CHANGED
@@ -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
|
213
|
+
Topic.import columns, valid_values
|
214
214
|
assert_difference "Topic.count", +2 do
|
215
|
-
Topic.import columns, valid_values
|
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.
|
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-
|
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.
|
187
|
+
rubygems_version: 2.6.11
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Bulk insert extension for ActiveRecord
|