Class: ActiveRecord::ConnectionAdapters::MysqlAdapter
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::MysqlAdapter
- Includes:
- SpatialAdapter::Base::Mysql::Adapter
- Defined in:
- lib/spatial_adapter/jdbcmysql.rb,
lib/spatial_adapter/mysql.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
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/spatial_adapter/jdbcmysql.rb', line 10 def columns(table_name, name = nil)#:nodoc: show_fields_from(table_name, name).map do |field| klass = \ if field["Type"] =~ GEOMETRY_REGEXP ActiveRecord::ConnectionAdapters::SpatialMysqlColumn else ActiveRecord::ConnectionAdapters::MysqlColumn end klass.new(field['Field'], field['Default'], field['Type'], field['Null'] == "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)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/spatial_adapter/jdbcmysql.rb', line 25 def indexes(table_name, name = nil)#:nodoc: indexes = [] current_index = nil show_keys_from(table_name, name).each do |row| if current_index != row['Key_name'] next if row['Key_name'] == "PRIMARY" # skip the primary key current_index = row['Key_name'] indexes << ActiveRecord::ConnectionAdapters::IndexDefinition \ .new(row['Table'], row['Key_name'], row['Non_unique'] == "0", [], row['Index_type'] == "SPATIAL") end indexes.last.columns << row['Column_name'] end indexes end |
#options_for(table) ⇒ Object
40 41 42 43 |
# File 'lib/spatial_adapter/jdbcmysql.rb', line 40 def (table) engine = show_table_status_like(table).first['Engine'] engine !~ /inno/i ? "ENGINE=#{engine}" : nil end |