Module: Imparcial::Driver::AbstractExpression::Index
- Included in:
- Imparcial::Driver::AbstractExpression
- Defined in:
- lib/imparcial/driver/abstract/expression/index.rb
Instance Method Summary collapse
-
#create_index(options = {}) ⇒ Object
Description Create an index.
- #drop_all_indexes(options = {}) ⇒ Object
- #drop_index(options = {}) ⇒ Object
- #expected_options_for_dropping_all_indexes ⇒ Object
-
#get_indexes(options = {}) ⇒ Object
Description Get metadata about all indexes.
-
#index_exists?(options = {}) ⇒ Boolean
Description Verify if a given index exists.
Instance Method Details
#create_index(options = {}) ⇒ Object
Description
Create an index.
Usage
abstract_adapter.create_index :index_name => ‘idx’, :table_name = ‘person’ ,:column_name => :id
Options
-
:index_name
-
:table_name
-
:column_name
-
:index_type
Returning
nothing
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/imparcial/driver/abstract/expression/index.rb', line 41 def create_index ( = {} ) , sql = sql_for_creating_index( ) logger.warn sql if @index_logging query sql rescue adapter_specific_exception => ex raise IndexCreateError.new(ex.) end |
#drop_all_indexes(options = {}) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/imparcial/driver/abstract/expression/index.rb', line 97 def drop_all_indexes ( = {} ) , for index in get_indexes(:table_name => [:table_name]) drop_index :table_name => index[:table], :index_name => index[:name] end end |
#drop_index(options = {}) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/imparcial/driver/abstract/expression/index.rb', line 73 def drop_index ( = {} ) , sql = sql_for_dropping_index( ) logger.warn sql if @index_logging query sql rescue adapter_specific_exception => ex raise IndexDropError.new(ex.) end |
#expected_options_for_dropping_all_indexes ⇒ Object
89 90 91 92 93 |
# File 'lib/imparcial/driver/abstract/expression/index.rb', line 89 def {:table_name => :required} end |
#get_indexes(options = {}) ⇒ Object
Description
Get metadata about all indexes.
Usage
abstract_adapter.retrieve_indexes
Options
No options
Returning
an array with hashes.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/imparcial/driver/abstract/expression/index.rb', line 137 def get_indexes ( = {} ) , sql = sql_for_getting_indexes logger.warn sql if @index_logging query sql indexes = [] result.fetch do |table, column, index| indexes << {:table => table.value,:column => column.value,:name => index.value} end indexes rescue adapter_specific_exception => ex raise IndexListError.new(ex.) end |
#index_exists?(options = {}) ⇒ Boolean
Description
Verify if a given index exists.
Usage
abstract_adapter.retrieve_indexes
Options
No options
Returning
true or false.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/imparcial/driver/abstract/expression/index.rb', line 185 def index_exists? ( = {} ) , sql = sql_for_index_exists?( ) logger.warn sql if @index_logging query sql result.rows > 0 rescue adapter_specific_exception => ex raise IndexDropError.new(ex.) end |