database_consistency 0.8.1 → 0.8.2

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: 20658faa1cdd6ae16c25dd7a9b2b85b608f81e2da8ffeb74f8f692ad5c8eb6cb
4
- data.tar.gz: 7a6c555f10de5253af9744eea4ada2c95525dd127d081e939ffa6ad6c4923bab
3
+ metadata.gz: 96d59f04ee02179f11d92477feb260aaa444c9b923ecbc142aa2b69ca12b3808
4
+ data.tar.gz: 6c79bf6d628c470a45976047ffcc608bddf07ff610f802a04542462b36ae4421
5
5
  SHA512:
6
- metadata.gz: 95ff5510806f67c8e612c488c608f2685e1abebbb3ecba455e706db34a104ab9c1135cac0193692884a7cb9f61301c91e0a27ea07d61eb08a3b89ca3dd5d952d
7
- data.tar.gz: 75a78627604fec92c8fd3703c70fa35e125139e188adf1d8592a480fcef44a50a6b4f670f2eaae139dd07c03ca397745b437d44fcdc35f96ea44b41aaaab6b7d
6
+ metadata.gz: 2c563868a70b3dd6cd1fe7d3f62481e6dee156c75a42a22f7e6ee43ce41d5ad08d6742d099c0a145a2b331726282ec2a71234ab1194361af655f18120e9c1b48
7
+ data.tar.gz: 4ccdf6f7647b4aac78a7378a15d7796f5ed35997f7f59ec77176ebbc55019faf3a0581852e52d529d7c11aa8d8f59a495295445ed39e0a81a2ec0b6a41f638e5
@@ -25,7 +25,7 @@ module DatabaseConsistency
25
25
  # | provided | ok |
26
26
  # | missing | fail |
27
27
  #
28
- # We consider PresenceValidation, InclusionValidation, ExclusionValidation with nil,
28
+ # We consider PresenceValidation, InclusionValidation, ExclusionValidation, NumericalityValidator with nil,
29
29
  # or BelongsTo association using this column
30
30
  def check
31
31
  if valid?
@@ -38,6 +38,7 @@ module DatabaseConsistency
38
38
  def valid?
39
39
  validator?(ActiveModel::Validations::PresenceValidator) ||
40
40
  validator?(ActiveModel::Validations::InclusionValidator) ||
41
+ numericality_validator_without_allow_nil? ||
41
42
  nil_exclusion_validator? ||
42
43
  belongs_to_association?
43
44
  end
@@ -57,6 +58,13 @@ module DatabaseConsistency
57
58
  end
58
59
  end
59
60
 
61
+ def numericality_validator_without_allow_nil?
62
+ model.validators.grep(ActiveModel::Validations::NumericalityValidator).any? do |validator|
63
+ Helper.check_inclusion?(validator.attributes, column.name) &&
64
+ !validator.options[:allow_nil]
65
+ end
66
+ end
67
+
60
68
  def validator?(validator_class)
61
69
  model.validators.grep(validator_class).any? do |validator|
62
70
  Helper.check_inclusion?(validator.attributes, column.name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
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: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-03 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.3'
125
- description:
125
+ description:
126
126
  email:
127
127
  - lawliet.djez@gmail.com
128
128
  executables:
@@ -160,7 +160,7 @@ homepage: https://github.com/djezzzl/database_consistency
160
160
  licenses:
161
161
  - MIT
162
162
  metadata: {}
163
- post_install_message:
163
+ post_install_message:
164
164
  rdoc_options: []
165
165
  require_paths:
166
166
  - lib
@@ -175,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.7.9
180
- signing_key:
178
+ rubygems_version: 3.1.2
179
+ signing_key:
181
180
  specification_version: 4
182
181
  summary: Provide an easy way to check the consistency of the database constraints
183
182
  with the application validations.