database_consistency 1.7.23 → 1.7.24

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: fa19d97c8acb835f248d400cf2083c32e8aa409c65155d997710d9bc2cda0c59
4
- data.tar.gz: a598e7238e279205af65c4101b0f8773bb90b6b816bed18850892a8d9cca4a0f
3
+ metadata.gz: b29d0d23f3eda8be6c71719df374c21bf7c69f749bdd5d9e71b658b7194e0a7a
4
+ data.tar.gz: 4dc387034661a53ce80a65513696da3bb5264b4097d1928268ca2cced6a2b082
5
5
  SHA512:
6
- metadata.gz: fb372c25d9da1c239739fbc4688f98f853ae8e17fd7ac238f8eeb4b359bbd5314d0a74eadeb38e783cf3ab383f38fb0762adfd956cc392879d03b1db5d68ac8a
7
- data.tar.gz: 0af3245696790d32ac16cf805038b110e8788390c3162646fcc4fb9f2e85bc343aab8db801decbcaa209bf6cf3a2db0f1f968c99bc0a016f8582e67752b56dfc
6
+ metadata.gz: 55f5c65ea75f3384bac11404204522c850d4637c884a6d08cc2b00201e874f74b246410527f6d619e41e35ef078bcca1f7dfce34709621a0a9d4c463b46d727f
7
+ data.tar.gz: 6bf767f48dfb95cbfce02f9a0fe49718adff8c2afc2e7ae7d74b9496b7991f11bc9f4da10c682cb36dbab310b92c7afc01f9b0b0073c03adaa51000f3f4d216d
@@ -45,8 +45,14 @@ module DatabaseConsistency
45
45
  end
46
46
 
47
47
  def valid?(sign)
48
- %i[maximum is].each do |option|
49
- return validator.options[option].public_send(sign, column.limit) if validator.options[option]
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
@@ -48,6 +48,12 @@ module DatabaseConsistency
48
48
  value
49
49
  end
50
50
 
51
+ def database_enabled?(name)
52
+ value = configuration.dig('DatabaseConsistencyDatabases', name, 'enabled')
53
+
54
+ value.nil? ? true : value
55
+ end
56
+
51
57
  private
52
58
 
53
59
  attr_reader :configuration
@@ -14,11 +14,10 @@ module DatabaseConsistency
14
14
 
15
15
  private
16
16
 
17
- def check # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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
@@ -43,6 +43,11 @@ module DatabaseConsistency
43
43
 
44
44
  private
45
45
 
46
+ def model_enabled?(model)
47
+ configuration.database_enabled?(Helper.database_name(model)) &&
48
+ configuration.enabled?(model.name.to_s)
49
+ end
50
+
46
51
  def check
47
52
  raise NotImplementedError
48
53
  end
@@ -15,11 +15,10 @@ module DatabaseConsistency
15
15
 
16
16
  private
17
17
 
18
- def check # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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/AbcSize, Metrics/MethodLength
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 configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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 configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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 # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
13
+ def check
14
14
  Helper.project_models.flat_map do |model|
15
15
  DebugContext.with(model: model.name) do
16
- next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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/AbcSize, Metrics/MethodLength
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 configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
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 configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '1.7.23'
4
+ VERSION = '1.7.24'
5
5
  end
@@ -23,7 +23,13 @@ module DatabaseConsistency
23
23
  end
24
24
 
25
25
  def columns
26
- "%w[#{report.columns.join(' ')}]"
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.23
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: 2023-12-18 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord