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.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#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, index_name, available_indexes) ⇒ IndexNotFound
constructor
A new instance of IndexNotFound.
Constructor Details
#initialize(columns, where_clause, index_name, available_indexes) ⇒ IndexNotFound
Returns a new instance of IndexNotFound.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/database_validations/validations/errors.rb', line 8 def initialize(columns, where_clause, index_name, available_indexes) @columns = columns @where_clause = where_clause @available_indexes = available_indexes @index_name = index_name text = if index_name "No unique index found with name: \"#{index_name}\". "\ "Available indexes are: #{self.available_indexes.map(&:name)}. " else "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(', ')}]. " end super text + "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 |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
6 7 8 |
# File 'lib/database_validations/validations/errors.rb', line 6 def index_name @index_name 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
25 26 27 |
# File 'lib/database_validations/validations/errors.rb', line 25 def columns_and_where_text(columns, where) "columns: #{columns}#{" and where: #{where}" if where}" end |