module ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SchemaStatements
Public Instance Methods
initialize_type_map(m = type_map)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb, line 46 def initialize_type_map(m = type_map) super %w[ geometry geometrycollection point linestring polygon multipoint multilinestring multipolygon ].each do |geo_type| m.register_type(geo_type) do |sql_type| Type::Spatial.new(sql_type) end end end
native_database_types()
click to toggle source
override
Calls superclass method
# File lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb, line 30 def native_database_types # Add spatial types # Reference: https://dev.mysql.com/doc/refman/5.6/en/spatial-type-overview.html super.merge( geometry: { name: "geometry" }, geometrycollection: { name: "geometrycollection" }, linestring: { name: "linestring" }, multi_line_string: { name: "multilinestring" }, multi_point: { name: "multipoint" }, multi_polygon: { name: "multipolygon" }, spatial: { name: "geometry" }, point: { name: "point" }, polygon: { name: "polygon" } ) end
Private Instance Methods
create_table_definition(*args, **options)
click to toggle source
override
# File lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb, line 73 def create_table_definition(*args, **options) Mysql2Rgeo::TableDefinition.new(self, *args, **options) end
new_column_from_field(table_name, field)
click to toggle source
override
# File lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb, line 78 def new_column_from_field(table_name, field) type_metadata = fetch_type_metadata(field[:Type], field[:Extra]) default, default_function = field[:Default], nil if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default) default, default_function = nil, default elsif type_metadata.extra == "DEFAULT_GENERATED" default = +"(#{default})" unless default.start_with?("(") default, default_function = nil, default end # {:dimension=>2, :has_m=>false, :has_z=>false, :name=>"latlon", :srid=>0, :type=>"GEOMETRY"} spatial = spatial_column_info(table_name).get(field[:Field], type_metadata.sql_type) SpatialColumn.new( field[:Field], default, type_metadata, field[:Null] == "YES", default_function, collation: field[:Collation], comment: field[:Comment].presence, spatial: spatial ) end
schema_creation()
click to toggle source
override
# File lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb, line 68 def schema_creation Mysql2Rgeo::SchemaCreation.new(self) end
spatial_column_info(table_name)
click to toggle source
memoize hash of column infos for tables
# File lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb, line 105 def spatial_column_info(table_name) @spatial_column_info ||= {} @spatial_column_info[table_name.to_sym] = SpatialColumnInfo.new(self, table_name.to_s) end