recheck 0.7.0 → 0.8.0

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: 50764d09b7fd317140ed5a0145f1420404044fc5a6c169b87871206fcdf80dec
4
- data.tar.gz: 05b29309e6f67ae7feabe036fc4f0362e9515c12b4abb7e4cd09b83a0d2d39bd
3
+ metadata.gz: 486a238104811d7c0c89f9139bce5a9d484f4394e3c23645e1329635a2d462c2
4
+ data.tar.gz: af3d9af6493d3b684c1047635ad2481f638ad89166d01f1f11fd99c3e57e615b
5
5
  SHA512:
6
- metadata.gz: d38baf414985cfd55e79d2159c55bd99b982031c11a04222d5d1178288dbd065013bfd422e5694a004585c430d6420452419c27e58c5b6d96653dafc842155c6
7
- data.tar.gz: f47fd053650743480c2cbdec6c12982464d0bdb3875ffd3fc445cdb009c3c2dbfb1c274d2bae75d43dead5d65913d2946da98caa3b8e53df09e2d36eaabb27d5
6
+ metadata.gz: '059a3fd50bc81f4788297e9c767094ea6fda175c4328ca6922778929c41612da1cec31e419a751e8705daf1b6a8409dd16185156947d5321a0f6976f109d113c'
7
+ data.tar.gz: c0237b5b87bcee83242f5c8a753eb89a61936519b9a2eedb1e39b071a832726b2c5a50e4bd036a1f126d892d399aecccd3e7c158f9c66793b913aca996774957
data/changelog.md CHANGED
@@ -1,4 +1,8 @@
1
- ## ## [Unreleased]
1
+ ## [Unreleased]
2
+
3
+ ## 0.8.0 - 2025-09-05
4
+
5
+ * Fixed generated check for ActiveRecord length validation
2
6
 
3
7
  ## 0.7.0 - 2025-09-05
4
8
 
@@ -94,25 +94,26 @@ module Recheck
94
94
  FunctionPlaceholder.new inspect:, name:, comment: "Coming soon to Recheck beta"
95
95
  when ActiveRecord::Validations::LengthValidator
96
96
  or_clauses = []
97
- if type == :stirng || type == :integer
97
+ if type == :string || type == :text || type == :integer
98
98
  if validator.options[:is]
99
99
  or_clauses << %{"LENGTH(`#{column.name}`) = '')"}
100
100
  end
101
101
  if validator.options[:minimum] && validator.options[:maximum]
102
- or_clauses << %{"LENGTH(`#{column.name}`) >= #{validator.options[:minimum]} and "LENGTH(`#{column.name}`) <= #{validator.options[:maximum]}}
102
+ or_clauses << %{"LENGTH(`#{column.name}`) <= #{validator.options[:minimum]} and LENGTH(`#{column.name}`) >= #{validator.options[:maximum]}"}
103
103
  elsif validator.options[:minimum]
104
- or_clauses << %{"LENGTH(`#{column.name}`) >= #{validator.options[:minimum]}}
104
+ or_clauses << %{"LENGTH(`#{column.name}`) <= #{validator.options[:minimum]}"}
105
105
  elsif validator.options[:maximum]
106
- or_clauses << %{"LENGTH(`#{column.name}`) <= #{validator.options[:maximum]}}
106
+ or_clauses << %{"LENGTH(`#{column.name}`) >= #{validator.options[:maximum]}"}
107
107
  end
108
108
  elsif type == :boolean
109
- comment = "Validating length of a boolean is backend-dependednt and a strange idea."
109
+ comment = "Validating length of a boolean is backend-dependent and a strange idea."
110
110
  else
111
- comment = "Recheck doesn't know how to handle presence on a #{type}, please report."
111
+ comment = "Recheck doesn't know how to handle length on a #{type}, please report."
112
112
  end
113
113
  if !validator.options[:allow_nil] && !validator.options[:allow_blank]
114
114
  or_clauses << "#{column.name}: nil"
115
115
  end
116
+ Query.new inspect:, name:, warning:, comment:, or_clauses:
116
117
  when ActiveRecord::Validations::NumericalityValidator
117
118
  FunctionPlaceholder.new inspect:, name:, comment: "Coming soon to Recheck beta"
118
119
  when ActiveRecord::Validations::PresenceValidator
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recheck
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -8,7 +8,7 @@ class <%= class_name %>ValidationChecker < Recheck::Checker::Base
8
8
  <%
9
9
  case query
10
10
  when Placeholder %>
11
- # <%= query.comment %>
11
+ # <%= query.comment -%>
12
12
  <%
13
13
  when FunctionPlaceholder
14
14
  %>
@@ -20,7 +20,7 @@ class <%= class_name %>ValidationChecker < Recheck::Checker::Base
20
20
  %><%= query.warning ? "# #{query.warning}" : "" %>
21
21
  def <%= query.name %>
22
22
  <%= query.comment ? "# #{query.comment}" : "" %>
23
- <%= class_name %>.where(<%= query.or_clauses.first %>)<%= (query.or_clauses[1..].map {".or(#{class_name}.where(#{it}))"}).join("") %>.find_each
23
+ <%= class_name %>.where(<%= query.or_clauses.first %>)<%= (query.or_clauses.drop(1).map {".or(#{class_name}.where(#{it}))"}).join("") %>.find_each
24
24
  end
25
25
  <%
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bhat Harkins