database_consistency 1.1.5 → 1.1.6
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482d9a79d349bbe6d49233cf8ffb05accbf61c9d30db72b8e2d9c5d5517602a6
|
4
|
+
data.tar.gz: 14309f3ef7aab0e6aa0d20e4f9a0c0148a2be89e30d09235fb558cc55085d38d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7abe1d2b81e1f557b20da7c61a33c9fab8ebe709dd459e78ec16c4b088b3a457b094985428d72f882c6e946d028a444bfaf6aa1058764f03aef6bb54c2ecd89c
|
7
|
+
data.tar.gz: d2b930d6d7a0f639c9f7f139f207d90df85af5409d918d77cf7f3c781602844220996eb3fef6639f0c490f33235efa74f92817a254eb5ee4930ec429c4a4c02d
|
@@ -42,6 +42,8 @@ module DatabaseConsistency
|
|
42
42
|
else
|
43
43
|
report_template(:fail, render_text)
|
44
44
|
end
|
45
|
+
rescue Errors::MissingField => e
|
46
|
+
report_template(:fail, e.message)
|
45
47
|
end
|
46
48
|
|
47
49
|
# @return [String]
|
@@ -101,8 +103,8 @@ module DatabaseConsistency
|
|
101
103
|
|
102
104
|
# @return [String]
|
103
105
|
def missing_field_error(table_name, column_name)
|
104
|
-
"
|
105
|
-
"field (#{column_name}) of table (#{table_name}) but it is missing
|
106
|
+
"association (#{association.name}) of class (#{association.active_record}) relies on "\
|
107
|
+
"field (#{column_name}) of table (#{table_name}) but it is missing"
|
106
108
|
end
|
107
109
|
|
108
110
|
# @param [ActiveRecord::ConnectionAdapters::Column] column
|
data/lib/database_consistency/checkers/validators_fraction_checkers/column_presence_checker.rb
CHANGED
@@ -29,8 +29,18 @@ module DatabaseConsistency
|
|
29
29
|
# | all missing | required | ok |
|
30
30
|
# | all missing | optional | fail |
|
31
31
|
def check
|
32
|
+
report_message
|
33
|
+
rescue Errors::MissingField => e
|
34
|
+
report_template(:fail, e.message)
|
35
|
+
end
|
36
|
+
|
37
|
+
def has_weak_option?
|
38
|
+
validators.all? { |validator| validator.options.slice(*WEAK_OPTIONS).any? }
|
39
|
+
end
|
40
|
+
|
41
|
+
def report_message
|
32
42
|
can_be_null = column.null
|
33
|
-
has_weak_option =
|
43
|
+
has_weak_option = has_weak_option?
|
34
44
|
|
35
45
|
return report_template(:ok) if can_be_null == has_weak_option
|
36
46
|
return report_template(:fail, POSSIBLE_NULL) unless can_be_null
|
@@ -44,7 +54,7 @@ module DatabaseConsistency
|
|
44
54
|
|
45
55
|
def column
|
46
56
|
@column ||= regular_column || association_reference_column ||
|
47
|
-
(raise Errors::MissingField, "
|
57
|
+
(raise Errors::MissingField, "column (#{attribute}) is missing in table (#{model.table_name}) but used for presence validation")
|
48
58
|
end
|
49
59
|
|
50
60
|
def regular_column
|
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.1.
|
4
|
+
version: 1.1.6
|
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-10
|
11
|
+
date: 2021-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|