Sha256: 901222f01b306150abf92e8d8c9979a593802c6ad71d8f4cd15cc0839fc604b9
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
require 'spatial_adapter' require 'spatial_adapter/base/mysql' require 'active_record/connection_adapters/jdbcmysql_adapter' module ActiveRecord::ConnectionAdapters class MysqlAdapter include SpatialAdapter::Base::Mysql::Adapter #Redefinition of columns to add the information that a column is geometric 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 # 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) 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 def options_for(table) engine = show_table_status_like(table).first['Engine'] engine !~ /inno/i ? "ENGINE=#{engine}" : nil end end class SpatialMysqlColumn < MysqlColumn include SpatialAdapter::SpatialColumn extend SpatialAdapter::Base::Mysql::SpatialColumn end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spatial_adapter-1.3.1 | lib/spatial_adapter/jdbcmysql.rb |
spatial_adapter-1.3.0 | lib/spatial_adapter/jdbcmysql.rb |