database_consistency 1.7.6 → 1.7.8
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: b117faf2434c91f017d6c1fd66af9b60dd39a320eb483d8c55dafa4870a79458
|
4
|
+
data.tar.gz: 4a9adb41296cad3b8c091b0bd62a4c5affa320e26c69fe8c68affc20cc7ea44e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddbe6952f4e66a77108d01e016f452e016bbb43dceafc6e8c666e92426c06e3d7d8f65a0bfa8d4253e3eacb81f9eee71364e5a5fe1c82941d6dd9ab90d70243
|
7
|
+
data.tar.gz: 4466ef032c16a72a174ffd030347ed96a914bbc3cf844d930b22afadb938782da8074fe142f6fca36933c2a2e241ddb57041f33ebef19b45e7b1b5f0edeeacf3
|
data/lib/database_consistency/checkers/validators_fraction_checkers/column_presence_checker.rb
CHANGED
@@ -38,18 +38,25 @@ module DatabaseConsistency
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def check
|
41
|
-
|
41
|
+
if regular_column
|
42
|
+
analyse(attribute.to_s, type: :null_constraint_missing)
|
43
|
+
else
|
44
|
+
analyse_association
|
45
|
+
end
|
46
|
+
end
|
42
47
|
|
48
|
+
def analyse_association
|
43
49
|
reports = [analyse(association.foreign_key.to_s, type: :association_missing_null_constraint)]
|
44
50
|
if association.polymorphic?
|
45
51
|
reports << analyse(association.foreign_type.to_s, type: :association_foreign_type_missing_null_constraint)
|
46
52
|
end
|
47
|
-
|
48
|
-
reports
|
53
|
+
reports.compact.presence
|
49
54
|
end
|
50
55
|
|
51
56
|
def analyse(column_name, type:)
|
52
57
|
field = column(column_name)
|
58
|
+
# If the column is missing there is nothing we can do.
|
59
|
+
return if field.nil?
|
53
60
|
|
54
61
|
can_be_null = field.null
|
55
62
|
has_weak_option = weak_option?
|
@@ -12,11 +12,20 @@ module DatabaseConsistency
|
|
12
12
|
assign_result(hash, result)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
sorted_hash = sort(h)
|
16
|
+
|
17
|
+
File.write(file_name, sorted_hash.to_yaml)
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
19
21
|
|
22
|
+
def sort(obj)
|
23
|
+
return obj unless obj.is_a?(Hash)
|
24
|
+
|
25
|
+
obj.sort_by { |(k, _)| k }
|
26
|
+
.to_h { |k, v| [k, sort(v)] }
|
27
|
+
end
|
28
|
+
|
20
29
|
def write?(status)
|
21
30
|
status == :fail
|
22
31
|
end
|
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.7.
|
4
|
+
version: 1.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|