Exception: DatabaseValidations::Errors::IndexNotFound
- Defined in:
- lib/database_validations/validations/errors.rb
Instance Attribute Summary collapse
-
#available_indexes ⇒ Object
readonly
Returns the value of attribute available_indexes.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#where_clause ⇒ Object
readonly
Returns the value of attribute where_clause.
Instance Method Summary collapse
- #columns_and_where_text(columns, where) ⇒ Object
-
#initialize(columns, where_clause, available_indexes) ⇒ IndexNotFound
constructor
A new instance of IndexNotFound.
Constructor Details
#initialize(columns, where_clause, available_indexes) ⇒ IndexNotFound
Returns a new instance of IndexNotFound.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/database_validations/validations/errors.rb', line 8 def initialize(columns, where_clause, available_indexes) @columns = columns.map(&:to_s) @where_clause = where_clause @available_indexes = available_indexes super "No unique index found with #{columns_and_where_text(columns, where_clause)}. "\ "Available indexes are: [#{self.available_indexes.map { |ind| columns_and_where_text(ind.columns, ind.where) }.join(', ')}]. "\ "Use ENV['SKIP_DB_UNIQUENESS_VALIDATOR_INDEX_CHECK']=true in case you want to skip the check. "\ "For example, when you run migrations." end |
Instance Attribute Details
#available_indexes ⇒ Object (readonly)
Returns the value of attribute available_indexes.
6 7 8 |
# File 'lib/database_validations/validations/errors.rb', line 6 def available_indexes @available_indexes end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/database_validations/validations/errors.rb', line 6 def columns @columns end |
#where_clause ⇒ Object (readonly)
Returns the value of attribute where_clause.
6 7 8 |
# File 'lib/database_validations/validations/errors.rb', line 6 def where_clause @where_clause end |
Instance Method Details
#columns_and_where_text(columns, where) ⇒ Object
19 20 21 |
# File 'lib/database_validations/validations/errors.rb', line 19 def columns_and_where_text(columns, where) "columns: #{columns}#{" and where: #{where}" if where}" end |