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
-
#create_table_definition(*args) ⇒ Object
override.
- #initialize_type_map(m) ⇒ Object
-
#native_database_types ⇒ Object
override.
-
#new_column(*args) ⇒ Object
override.
-
#type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil) ⇒ Object
:nodoc:.
Instance Method Details
#create_table_definition(*args) ⇒ Object
override
36 37 38 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 36 def create_table_definition(*args) Mysql2Rgeo::TableDefinition.new(*args) end |
#initialize_type_map(m) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 40 def initialize_type_map(m) super %w( geometry point linestring polygon geometrycollection multipoint multilinestring multipolygon ).each do |geo_type| m.register_type(geo_type, Type::Spatial.new(geo_type)) end end |
#native_database_types ⇒ Object
override
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 20 def native_database_types # Add spatial types super.merge( geometry: { name: "geometry" }, point: { name: "point" }, linestring: { name: "linestring" }, polygon: { name: "polygon" }, multi_geometry: { name: "geometrycollection" }, multi_point: { name: "multipoint" }, multi_linestring: { name: "multilinestring" }, multi_polygon: { name: "multipolygon" }, spatial: { name: "geometry", limit: { type: :point } } ) end |
#new_column(*args) ⇒ Object
override
6 7 8 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 6 def new_column(*args) SpatialColumn.new(*args) end |
#type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil) ⇒ Object
:nodoc:
10 11 12 13 14 15 16 17 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb', line 10 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 = :geometry if type.eql? :spatial type = type.to_s.delete("_").upcase end super end |