database_validations 1.1.0 → 1.1.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
  SHA256:
3
- metadata.gz: d4f713f4e6cffee98b4e7825fa18de17fdd25780659d0bea75f8fbc90ada6ecd
4
- data.tar.gz: 73d3f1d54aaea77a61fbc3fcb221348be0ffcb6430eaeec98c09d6cd1e4ca9a7
3
+ metadata.gz: 397b350ccf27a15694e155a4bb21bae6a01fe94cacceaa14aff89d1db6f542c1
4
+ data.tar.gz: da042f3adbf3b00a1b85e01a8dd740b23dec523379adc1c5500f1a367f2a0391
5
5
  SHA512:
6
- metadata.gz: 84927dd603f9f8bf8de7fbe98b5414e40de5c30f3d6adb95f5e1c77eef85c8fb7caef58c618e70ce3272feb6407cba159ce36b294d871eb793b30042b3bc5c28
7
- data.tar.gz: b51be17960b5f2ad13ca0c6e128dc3352d5bfc53b94ecd1ea40edf1448da300ba546cf1c94e8965b839f29ea693bb1369a4bee7b1ba92f90e7d256544eec906c
6
+ metadata.gz: bf357e666a546058018322985ffe4a342d3004d9105c11bcd9e9eeb9b904ce8ecc915960783987b6b57cab8cca26c63eb7d6a788e74f581dc2e8e566f3a32bf9
7
+ data.tar.gz: 8c9d658eff8041b6237c3b554b82dee7ca390a833aafdfd5d0fc4c7fa6f730241f5a9412c0a8b171ae4df1323e53e1fed796d6782df83b166a76cb78a26ab5e7
@@ -14,14 +14,14 @@ module DatabaseValidations
14
14
  end
15
15
 
16
16
  def validate!
17
- validate_foreign_keys! unless ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK']
17
+ return if ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK']
18
+
19
+ validate_foreign_keys! unless validator.klass.abstract_class?
18
20
  end
19
21
 
20
22
  private
21
23
 
22
- def validate_foreign_keys! # rubocop:disable Metrics/AbcSize
23
- adapter = Adapters::BaseAdapter.new(validator.klass)
24
-
24
+ def validate_foreign_keys!(adapter = Adapters::BaseAdapter.new(validator.klass))
25
25
  validator.attributes.each do |attribute|
26
26
  reflection = validator.klass._reflect_on_association(attribute)
27
27
 
@@ -16,7 +16,9 @@ module DatabaseValidations
16
16
  def validate!
17
17
  validate_index_usage!
18
18
 
19
- validate_indexes! unless ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK']
19
+ return if ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK']
20
+
21
+ validate_indexes!(validator.klass) unless validator.klass.abstract_class?
20
22
  end
21
23
 
22
24
  private
@@ -33,8 +35,8 @@ module DatabaseValidations
33
35
  raise ArgumentError, "When index_name is provided validator can have only one attribute. See #{validator.inspect}"
34
36
  end
35
37
 
36
- def validate_indexes! # rubocop:disable Metrics/AbcSize
37
- adapter = Adapters::BaseAdapter.new(validator.klass)
38
+ def validate_indexes!(klass) # rubocop:disable Metrics/AbcSize
39
+ adapter = Adapters::BaseAdapter.new(klass)
38
40
 
39
41
  validator.attributes.map do |attribute|
40
42
  columns = KeyGenerator.unify_columns(attribute, validator.options[:scope])
@@ -1,3 +1,3 @@
1
1
  module DatabaseValidations
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord