database_consistency 1.3.0 → 1.3.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
|
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
|
@@ -195,10 +195,19 @@ homepage: https://github.com/djezzzl/database_consistency
|
|
195
195
|
licenses:
|
196
196
|
- MIT
|
197
197
|
metadata: {}
|
198
|
-
post_install_message:
|
199
|
-
|
200
|
-
|
201
|
-
|
198
|
+
post_install_message: |2+
|
199
|
+
|
200
|
+
Thank you for using the gem!
|
201
|
+
|
202
|
+
If the project helps you or your organization, I would be very grateful if you contribute or donate.
|
203
|
+
Your support is an incredible motivation and the biggest reward for my hard work.
|
204
|
+
|
205
|
+
https://github.com/djezzzl/database_consistency#contributing
|
206
|
+
https://opencollective.com/database_consistency#support
|
207
|
+
|
208
|
+
Thank you for your attention,
|
209
|
+
Evgeniy Demin
|
210
|
+
|
202
211
|
rdoc_options: []
|
203
212
|
require_paths:
|
204
213
|
- lib
|