activerecord-import 0.28.1 → 0.28.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/activerecord-import/import.rb +23 -17
- data/lib/activerecord-import/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39f2e5b83b07075c09bba10e3c9a53953b484641
|
4
|
+
data.tar.gz: 28869f9586c6200e932a34dadbed9f4790ee820d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad31c1f3f11c1b6ba63cf2c5e65d71713603cb7604cac06e35d2786f34394e88a2ad69bc76fcaf14d7cd90e84fa277e84427425aa27cd0bcb65c61024990e1a
|
7
|
+
data.tar.gz: e842906754fd995d1be896e7929213919426ccf9c107f06c996c0216b9331c3232ff85ceb622c9de4678de6ff639e22ee783c5482bb9fbdb8c5740df46d55304
|
data/CHANGELOG.md
CHANGED
@@ -32,33 +32,39 @@ module ActiveRecord::Import #:nodoc:
|
|
32
32
|
def init_validations(klass)
|
33
33
|
@validate_callbacks = klass._validate_callbacks.dup
|
34
34
|
|
35
|
-
|
35
|
+
@validate_callbacks.each_with_index do |callback, i|
|
36
36
|
filter = callback.raw_filter
|
37
|
+
next unless filter.class.name =~ /Validations::PresenceValidator/ ||
|
38
|
+
(!@options[:validate_uniqueness] &&
|
39
|
+
filter.is_a?(ActiveRecord::Validations::UniquenessValidator))
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
callback = callback.dup
|
42
|
+
filter = filter.dup
|
43
|
+
attrs = filter.instance_variable_get(:@attributes).dup
|
44
|
+
|
45
|
+
if filter.is_a?(ActiveRecord::Validations::UniquenessValidator)
|
46
|
+
attrs = []
|
47
|
+
else
|
41
48
|
associations = klass.reflect_on_all_associations(:belongs_to)
|
42
|
-
attrs = filter.instance_variable_get(:@attributes).dup
|
43
49
|
associations.each do |assoc|
|
44
50
|
if (index = attrs.index(assoc.name))
|
45
51
|
key = assoc.foreign_key.to_sym
|
46
52
|
attrs[index] = key unless attrs.include?(key)
|
47
53
|
end
|
48
54
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
callback.filter = callback.send(:_compile_filter, filter)
|
58
|
-
@validate_callbacks[i] = callback
|
55
|
+
end
|
56
|
+
|
57
|
+
filter.instance_variable_set(:@attributes, attrs)
|
58
|
+
|
59
|
+
if @validate_callbacks.respond_to?(:chain, true)
|
60
|
+
@validate_callbacks.send(:chain).tap do |chain|
|
61
|
+
callback.instance_variable_set(:@filter, filter)
|
62
|
+
chain[i] = callback
|
59
63
|
end
|
60
|
-
|
61
|
-
|
64
|
+
else
|
65
|
+
callback.raw_filter = filter
|
66
|
+
callback.filter = callback.send(:_compile_filter, filter)
|
67
|
+
@validate_callbacks[i] = callback
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
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.28.
|
4
|
+
version: 0.28.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|