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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397b350ccf27a15694e155a4bb21bae6a01fe94cacceaa14aff89d1db6f542c1
|
4
|
+
data.tar.gz: da042f3adbf3b00a1b85e01a8dd740b23dec523379adc1c5500f1a367f2a0391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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!
|
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
|
-
|
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(
|
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])
|
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.
|
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:
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|