Class: ActiveRecord::ConnectionAdapters::Mysql2Adapter
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::Mysql2Adapter
- Includes:
- SpatialAdapter::Base::Mysql::Adapter
- Defined in:
- lib/spatial_adapter/mysql2.rb
Constant Summary
Constants included from SpatialAdapter::Base::Mysql::Adapter
SpatialAdapter::Base::Mysql::Adapter::GEOMETRY_REGEXP
Instance Method Summary collapse
-
#columns(table_name, name = nil) ⇒ Object
Redefinition of columns to add the information that a column is geometric.
-
#indexes(table_name, name = nil) ⇒ Object
Check the nature of the index : If it is SPATIAL, it is indicated in the IndexDefinition object (redefined to add the spatial flag in spatial_adapter_common.rb).
- #options_for(table) ⇒ Object
Methods included from SpatialAdapter::Base::Mysql::Adapter
included, #supports_geographic?
Instance Method Details
#columns(table_name, name = nil) ⇒ Object
Redefinition of columns to add the information that a column is geometric
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/spatial_adapter/mysql2.rb', line 15 def columns(table_name, name = nil)#:nodoc: show_fields_from(table_name, name).map do |field| klass = \ if field[1] =~ GEOMETRY_REGEXP ActiveRecord::ConnectionAdapters::SpatialMysql2Column else ActiveRecord::ConnectionAdapters::Mysql2Column end klass.new(field[0], field[4], field[1], field[2] == "YES") end end |
#indexes(table_name, name = nil) ⇒ Object
Check the nature of the index : If it is SPATIAL, it is indicated in the IndexDefinition object (redefined to add the spatial flag in spatial_adapter_common.rb)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/spatial_adapter/mysql2.rb', line 30 def indexes(table_name, name = nil)#:nodoc: indexes = [] current_index = nil show_keys_from(table_name, name).each do |row| if current_index != row[2] next if row[2] == "PRIMARY" # skip the primary key current_index = row[2] indexes << ActiveRecord::ConnectionAdapters::IndexDefinition \ .new(row[0], row[2], row[1] == "0", [], row[10] == "SPATIAL") end indexes.last.columns << row[4] end indexes end |
#options_for(table) ⇒ Object
45 46 47 48 |
# File 'lib/spatial_adapter/mysql2.rb', line 45 def (table) engine = show_table_status_like(table).first[1] engine !~ /inno/i ? "ENGINE=#{engine}" : nil end |