database_consistency 1.7.22 → 1.7.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/database_consistency/checkers/column_checkers/enum_value_checker.rb +2 -2
- data/lib/database_consistency/checkers/column_checkers/length_constraint_checker.rb +8 -2
- data/lib/database_consistency/configuration.rb +6 -0
- data/lib/database_consistency/processors/associations_processor.rb +2 -3
- data/lib/database_consistency/processors/base_processor.rb +5 -0
- data/lib/database_consistency/processors/columns_processor.rb +2 -3
- data/lib/database_consistency/processors/enums_processor.rb +2 -3
- data/lib/database_consistency/processors/indexes_processor.rb +1 -2
- data/lib/database_consistency/processors/models_processor.rb +2 -3
- data/lib/database_consistency/processors/validators_fractions_processor.rb +2 -3
- data/lib/database_consistency/processors/validators_processor.rb +2 -3
- data/lib/database_consistency/version.rb +1 -1
- data/lib/database_consistency/writers/autofix/association_missing_index.rb +7 -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: b29d0d23f3eda8be6c71719df374c21bf7c69f749bdd5d9e71b658b7194e0a7a
|
4
|
+
data.tar.gz: 4dc387034661a53ce80a65513696da3bb5264b4097d1928268ca2cced6a2b082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f5c65ea75f3384bac11404204522c850d4637c884a6d08cc2b00201e874f74b246410527f6d619e41e35ef078bcca1f7dfce34709621a0a9d4c463b46d727f
|
7
|
+
data.tar.gz: 6bf767f48dfb95cbfce02f9a0fe49718adff8c2afc2e7ae7d74b9496b7991f11bc9f4da10c682cb36dbab310b92c7afc01f9b0b0073c03adaa51000f3f4d216d
|
@@ -44,7 +44,7 @@ module DatabaseConsistency
|
|
44
44
|
def verify_enum
|
45
45
|
values = enum.values.uniq
|
46
46
|
|
47
|
-
if enum_column_values == values
|
47
|
+
if enum_column_values.sort == values.sort
|
48
48
|
report_template(:ok, values)
|
49
49
|
else
|
50
50
|
report_template(:fail, values, error_slug: :enum_values_inconsistent_with_ar_enum)
|
@@ -54,7 +54,7 @@ module DatabaseConsistency
|
|
54
54
|
def verify_inclusion_validator
|
55
55
|
values = validator_values(inclusion_validator).uniq
|
56
56
|
|
57
|
-
if enum_column_values == values
|
57
|
+
if enum_column_values.sort == values.sort
|
58
58
|
report_template(:ok, values)
|
59
59
|
else
|
60
60
|
report_template(:fail, values, error_slug: :enum_values_inconsistent_with_inclusion)
|
@@ -45,8 +45,14 @@ module DatabaseConsistency
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def valid?(sign)
|
48
|
-
%i[maximum is].each do |
|
49
|
-
|
48
|
+
%i[maximum is].each do |key|
|
49
|
+
option = validator.options[key]
|
50
|
+
next unless option
|
51
|
+
|
52
|
+
# skipping runtime-calculated limits
|
53
|
+
return true if option.is_a?(Proc) || option.is_a?(Symbol)
|
54
|
+
|
55
|
+
return option.public_send(sign, column.limit)
|
50
56
|
end
|
51
57
|
|
52
58
|
false
|
@@ -14,11 +14,10 @@ module DatabaseConsistency
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def check # rubocop:disable Metrics/
|
17
|
+
def check # rubocop:disable Metrics/MethodLength
|
18
18
|
Helper.models.flat_map do |model|
|
19
19
|
DebugContext.with(model: model.name) do
|
20
|
-
next unless
|
21
|
-
configuration.enabled?(model.name.to_s)
|
20
|
+
next unless model_enabled?(model)
|
22
21
|
|
23
22
|
Helper.first_level_associations(model).flat_map do |association|
|
24
23
|
DebugContext.with(association: association.name) do
|
@@ -15,11 +15,10 @@ module DatabaseConsistency
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def check # rubocop:disable Metrics/
|
18
|
+
def check # rubocop:disable Metrics/MethodLength
|
19
19
|
Helper.parent_models.flat_map do |model|
|
20
20
|
DebugContext.with(model: model.name) do
|
21
|
-
next unless
|
22
|
-
configuration.enabled?(model.name.to_s)
|
21
|
+
next unless model_enabled?(model)
|
23
22
|
|
24
23
|
model.columns.flat_map do |column|
|
25
24
|
DebugContext.with(column: column.name) do
|
@@ -10,11 +10,10 @@ module DatabaseConsistency
|
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
def check # rubocop:disable Metrics/
|
13
|
+
def check # rubocop:disable Metrics/MethodLength
|
14
14
|
Helper.models.flat_map do |model|
|
15
15
|
DebugContext.with(model: model.name) do
|
16
|
-
next unless
|
17
|
-
configuration.enabled?(model.name.to_s)
|
16
|
+
next unless model_enabled?(model)
|
18
17
|
|
19
18
|
model.defined_enums.keys.flat_map do |enum|
|
20
19
|
DebugContext.with(enum: enum) do
|
@@ -15,8 +15,7 @@ module DatabaseConsistency
|
|
15
15
|
def check # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
16
16
|
Helper.parent_models.flat_map do |model|
|
17
17
|
DebugContext.with(model: model.name) do
|
18
|
-
next unless
|
19
|
-
configuration.enabled?(model.name.to_s)
|
18
|
+
next unless model_enabled?(model)
|
20
19
|
|
21
20
|
indexes = model.connection.indexes(model.table_name)
|
22
21
|
|
@@ -10,11 +10,10 @@ module DatabaseConsistency
|
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
def check
|
13
|
+
def check
|
14
14
|
Helper.project_models.flat_map do |model|
|
15
15
|
DebugContext.with(model: model.name) do
|
16
|
-
next unless
|
17
|
-
configuration.enabled?(model.name.to_s)
|
16
|
+
next unless model_enabled?(model)
|
18
17
|
|
19
18
|
enabled_checkers.flat_map do |checker_class|
|
20
19
|
DebugContext.with(checker: checker_class) do
|
@@ -11,11 +11,10 @@ module DatabaseConsistency
|
|
11
11
|
private
|
12
12
|
|
13
13
|
# @return [Array<Hash>]
|
14
|
-
def check # rubocop:disable Metrics/
|
14
|
+
def check # rubocop:disable Metrics/MethodLength
|
15
15
|
Helper.parent_models.flat_map do |model|
|
16
16
|
DebugContext.with(model: model.name) do
|
17
|
-
next unless
|
18
|
-
configuration.enabled?(model.name.to_s)
|
17
|
+
next unless model_enabled?(model)
|
19
18
|
|
20
19
|
model._validators.flat_map do |attribute, validators|
|
21
20
|
DebugContext.with(attribute: attribute) do
|
@@ -12,11 +12,10 @@ module DatabaseConsistency
|
|
12
12
|
private
|
13
13
|
|
14
14
|
# @return [Array<Hash>]
|
15
|
-
def check # rubocop:disable Metrics/
|
15
|
+
def check # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
16
16
|
Helper.parent_models.flat_map do |model|
|
17
17
|
DebugContext.with(model: model.name) do
|
18
|
-
next unless
|
19
|
-
configuration.enabled?(model.name.to_s)
|
18
|
+
next unless model_enabled?(model)
|
20
19
|
|
21
20
|
model.validators.flat_map do |validator|
|
22
21
|
next unless validator.respond_to?(:attributes)
|
@@ -23,7 +23,13 @@ module DatabaseConsistency
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def columns
|
26
|
-
|
26
|
+
if report.columns.size > 1
|
27
|
+
"%w[#{report.columns.join(' ')}]"
|
28
|
+
elsif report.columns.first =~ /[()]/
|
29
|
+
"'#{report.columns.first}'"
|
30
|
+
else
|
31
|
+
":#{report.columns.first}"
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
def columns_key
|
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.24
|
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: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|