Module: ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SchemaStatements

Included in:
ActiveRecord::ConnectionAdapters::Mysql2RgeoAdapter
Defined in:
lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb

Instance Method Summary collapse

Instance Method Details

#indexes(table_name) ⇒ Object

override



10
11
12
13
14
15
16
17
18
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 10

def indexes(table_name) #:nodoc:
  indexes = super
  # HACK(aleks, 06/15/18): MySQL 5 does not support prefix lengths for spatial indexes
  # https://dev.mysql.com/doc/refman/5.6/en/create-index.html
  indexes.select do |idx|
    idx.type == :spatial
  end.each { |idx| idx.is_a?(Struct) ? idx.lengths = {} : idx.instance_variable_set(:@lengths, {}) }
  indexes
end

#type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil) ⇒ Object

override



21
22
23
24
25
26
27
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 21

def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
  if (info = RGeo::ActiveRecord.geometric_type_from_name(type.to_s.delete("_")))
    type = limit[:type] || type if limit.is_a?(::Hash)
    type = type.to_s.delete("_").upcase
  end
  super
end