database_consistency 1.3.1 → 1.3.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/lib/database_consistency/helper.rb +9 -3
- data/lib/database_consistency/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c1477361d612a93d643987fff549de519a50d8452b1019c04f32766598078a
|
4
|
+
data.tar.gz: 5132d1568f2573ef5a2bfdeb34321d29f8bc4938f2cc7fa3e75e383dec8a22d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b9c74967fa7143dca1606de94d9ff18ed48553a1dc916a255f012e22f2509ead5ed943ec1b331fdac9bd11a41a5a0c5549948b9961ace82c374b17dfa9b064
|
7
|
+
data.tar.gz: 59cfde80772740f400642739011136f1292dc9c34540835f534f77cac7c2fe4a25d44dc279553b29ee93137dfb718815a08c07b663fd1e8c5fa949fa3003b0da
|
@@ -78,17 +78,23 @@ module DatabaseConsistency
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def uniqueness_validator_columns(attribute, validator, model)
|
81
|
-
([wrapped_attribute_name(attribute, validator)] + scope_columns(validator, model)).map(&:to_s)
|
81
|
+
([wrapped_attribute_name(attribute, validator, model)] + scope_columns(validator, model)).map(&:to_s)
|
82
82
|
end
|
83
83
|
|
84
84
|
def scope_columns(validator, model)
|
85
85
|
Array.wrap(validator.options[:scope]).map do |scope_item|
|
86
|
-
model
|
86
|
+
foreign_key_or_attribute(model, scope_item)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
def foreign_key_or_attribute(model, attribute)
|
91
|
+
model._reflect_on_association(attribute)&.foreign_key || attribute
|
92
|
+
end
|
93
|
+
|
90
94
|
# @return [String]
|
91
|
-
def wrapped_attribute_name(attribute, validator)
|
95
|
+
def wrapped_attribute_name(attribute, validator, model)
|
96
|
+
attribute = foreign_key_or_attribute(model, attribute)
|
97
|
+
|
92
98
|
if validator.options[:case_sensitive].nil? || validator.options[:case_sensitive]
|
93
99
|
attribute
|
94
100
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_consistency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|