database_consistency 2.0.6 → 2.0.8

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: a6008fb2151b236c23471bb000bafc433347f3e688f93ccfab02dd1c33008f21
4
- data.tar.gz: dbf2cf3bedae1a4e7595be03a0c85c960d3fca7a15af902aac5d2b32d4ff5a1b
3
+ metadata.gz: 3093f4a5d4db53c187939d87a5799b5a932d9ddb6d7c4d124949e66e2ea14477
4
+ data.tar.gz: d7c73224a9f1006113ad57b8a6a740f5198bcbe2ba7b855cdaac9d34b8794f87
5
5
  SHA512:
6
- metadata.gz: 6fcf39eab6149c46d1971fdbbf577494eaaf4388518ec1863672f1043f6c3fb0fe55580384752db85900f9ff94a6e6e1016d065a363c9d6e1d4dfe60014101e1
7
- data.tar.gz: 035e0959fb1adadf7027279b52a302ade943c7c6cfd122742085154f6b867247b8bbbdc7beb9398b3ad559d0c568fadc9333d0cc7aa74c819100e7434bd8f75b
6
+ metadata.gz: e0b3a3e3507c77692ffcd1b89430e561bf9c51f1d5419ab5cd176667048c747d03bf9ca0789a60bd02e5e2deac6e666556f0d1c4cc95c666c66b4ee48562e0f6
7
+ data.tar.gz: 3fa45f23b358a9ce3ab83be7512c6ec7d59c9ae6bf7b5ec39c50f26ddaa0063fb7a31dd2779d67e946222ef7aea0186d1ad1b7383a4c482424b01c6dda1348b4
@@ -69,7 +69,7 @@ module DatabaseConsistency
69
69
  model.validators.any? do |validator|
70
70
  validator.kind == :exclusion &&
71
71
  Helper.check_inclusion?(validator.attributes, column.name) &&
72
- validator.options[:in].include?(nil)
72
+ Helper.inclusion_validator_values(validator).include?(nil)
73
73
  end
74
74
  end
75
75
 
@@ -16,7 +16,7 @@ module DatabaseConsistency
16
16
  # We skip check when:
17
17
  # - index is unique
18
18
  def preconditions
19
- !index.unique
19
+ !index.unique && Helper.btree_index?(index)
20
20
  end
21
21
 
22
22
  # Table of possible statuses
@@ -48,7 +48,7 @@ module DatabaseConsistency
48
48
  def covered_by_index
49
49
  @covered_by_index ||=
50
50
  model.connection.indexes(model.table_name).find do |another_index|
51
- next if index.name == another_index.name
51
+ next if index.name == another_index.name || !Helper.btree_index?(another_index)
52
52
 
53
53
  clause_equals?(another_index) && include_index_as_prefix?(another_index)
54
54
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DatabaseConsistency
4
4
  # The module contains helper methods
5
- module Helper
5
+ module Helper # rubocop:disable Metrics/ModuleLength
6
6
  module_function
7
7
 
8
8
  def adapter
@@ -112,6 +112,21 @@ module DatabaseConsistency
112
112
  end
113
113
  end
114
114
 
115
+ def inclusion_validator_values(validator)
116
+ value = validator.options[:in]
117
+
118
+ if value.is_a?(Proc) && value.arity.zero?
119
+ value.call
120
+ else
121
+ Array.wrap(value)
122
+ end
123
+ end
124
+
125
+ def btree_index?(index)
126
+ (index.type.nil? || index.type.to_s == 'btree') &&
127
+ (index.using.nil? || index.using.to_s == 'btree')
128
+ end
129
+
115
130
  def extract_columns(str)
116
131
  str.scan(/(\w+)/).flatten
117
132
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '2.0.6'
4
+ VERSION = '2.0.8'
5
5
  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: 2.0.6
4
+ version: 2.0.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: 2025-09-25 00:00:00.000000000 Z
11
+ date: 2025-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord