activerecord-import 0.28.1 → 0.28.2

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: dbd7badbb2e98c6725ddaf5edbb713c4f79bfc01
4
- data.tar.gz: 0912df3959070820db94063d0172a43f4b027a9f
3
+ metadata.gz: 39f2e5b83b07075c09bba10e3c9a53953b484641
4
+ data.tar.gz: 28869f9586c6200e932a34dadbed9f4790ee820d
5
5
  SHA512:
6
- metadata.gz: 22fb70781c58df1795c41e5b8e954b8a89e6c85be0dbf33f2c2fb9265847778f99f414cbd7fe9ea945d6aa43f89d7557ea41541f938fa357a7bbcb2c0e6114df
7
- data.tar.gz: b480446464f626518ac128b2e79d4e4dbb2b50e8e52d6781812a0ee1594e5328430214ad03be9590c09dcfd07661ae54130b53ccde1b9b7d2131d2f40c80a633
6
+ metadata.gz: dad31c1f3f11c1b6ba63cf2c5e65d71713603cb7604cac06e35d2786f34394e88a2ad69bc76fcaf14d7cd90e84fa277e84427425aa27cd0bcb65c61024990e1a
7
+ data.tar.gz: e842906754fd995d1be896e7929213919426ccf9c107f06c996c0216b9331c3232ff85ceb622c9de4678de6ff639e22ee783c5482bb9fbdb8c5740df46d55304
@@ -1,3 +1,10 @@
1
+ ## Changes in 0.28.2
2
+
3
+ ### Fixes
4
+
5
+ * Fix issue where validations where not working in certain scenarios.
6
+ Thanks to @CASIXx1 via \#579.
7
+
1
8
  ## Changes in 0.28.1
2
9
 
3
10
  ### Fixes
@@ -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
- klass._validate_callbacks.each_with_index do |callback, i|
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
- if filter.class.name =~ /Validations::PresenceValidator/
39
- callback = callback.dup
40
- filter = filter.dup
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
- filter.instance_variable_set(:@attributes, attrs)
50
- if @validate_callbacks.respond_to?(:chain, true)
51
- @validate_callbacks.send(:chain).tap do |chain|
52
- callback.instance_variable_set(:@filter, filter)
53
- chain[i] = callback
54
- end
55
- else
56
- callback.raw_filter = filter
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
- elsif !@options[:validate_uniqueness] && filter.is_a?(ActiveRecord::Validations::UniquenessValidator)
61
- @validate_callbacks.delete(callback)
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.28.1".freeze
3
+ VERSION = "0.28.2".freeze
4
4
  end
5
5
  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.1
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-04 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord