Class: ActiveRecord::ConnectionAdapters::Mysql2Rgeo::TableDefinition

Inherits:
MySQL::TableDefinition
  • Object
show all
Includes:
ColumnMethods
Defined in:
lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from ColumnMethods

#geometry, #geometrycollection, #linestring, #multilinestring, #multipoint, #multipolygon, #point, #polygon, #spatial

Instance Method Details

#new_column_definition(name, type, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb', line 8

def new_column_definition(name, type, options)
  if (info = Mysql2RgeoAdapter.spatial_column_options(type.to_sym))
    if (limit = options.delete(:limit))
      options.merge!(limit) if limit.is_a?(::Hash)
    end

    geo_type = ColumnDefinitionUtils.geo_type(options[:type] || type || info[:type])
    base_type = info[:type] || :geometry

    # puts name.dup << " - " << type.to_s << " - " << options.to_s << " :: " << geo_type.to_s << " - " << base_type.to_s

    options[:spatial_type] = geo_type
    column = super(name, geo_type.downcase.to_sym, options)
  else
    column = super(name, type, options)
  end

  column
end