Class: DatabaseConsistency::Checkers::NumericalityConstraintChecker

Inherits:
ValidatorsFractionChecker show all
Defined in:
lib/database_consistency/checkers/validators_fraction_checkers/numericality_constraint_checker.rb

Overview

This class checks if numericality validator has check constraint in the database

Constant Summary collapse

SQL_KEYWORDS =
%w[
  and or not null is true false in like between case when then else end check
  exists select where having order group limit offset distinct all any some
  from join on using as by union into values set update delete insert with
].freeze
PLAIN_IDENTIFIER_PATTERN =
/\b([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)?)\b(?!\s*\()/.freeze
RANGE_OPTIONS =

Without one of these options, numericality only asserts "is a number", which the column's numeric type already guarantees. There is no corresponding CHECK constraint to look for in that case, so validators with none of these options are skipped. Listed explicitly rather than excluding the known non-range options (only_integer, allow_nil, ...) so that an unrecognized option never makes us demand a constraint that cannot exist. The tradeoff is that a future range option must be added here to be reported on.

%i[
  greater_than greater_than_or_equal_to
  less_than less_than_or_equal_to
  equal_to other_than in
].freeze

Instance Attribute Summary

Attributes inherited from ValidatorsFractionChecker

#attribute, #model, #validators

Method Summary

Methods inherited from ValidatorsFractionChecker

#column_or_attribute_name, #initialize, processor, #table_or_model_name

Methods inherited from BaseChecker

checker_name, enabled?, #enabled?, inherited, #report, #report_if_enabled?

Constructor Details

This class inherits a constructor from DatabaseConsistency::Checkers::ValidatorsFractionChecker