Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed GeomFromWKB to ST_GeomFromWKB, as GeomFromWKB is deprecated in mysql5.7+ #36

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class MySQL2Spatial < MySQL
end

FUNC_MAP = {
'st_wkttosql' => 'GeomFromText',
'st_wkbtosql' => 'GeomFromWKB',
'st_length' => 'GLength'
}.freeze
'st_wkttosql' => 'ST_GeomFromText',
'st_wkbtosql' => 'ST_GeomFromWKB',
'st_length' => 'ST_GLength'
}

include ::RGeo::ActiveRecord::SpatialToSql

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def point(name, options = {})
end
end

ConnectionAdapters::TableDefinition.include ColumnMethods
ConnectionAdapters::TableDefinition.send(:include, ColumnMethods)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def native_database_types

def quote(value_, column_ = nil)
if ::RGeo::Feature::Geometry.check_type(value_)
"GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(hex_format: true).generate(value_)},#{value_.srid})"
"ST_GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(hex_format: true).generate(value_)},#{value_.srid})"
else
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ module Mysql2SpatialAdapter
ConnectionAdapters::Mysql2Adapter::Column : ConnectionAdapters::Mysql2Column

class SpatialColumn < column_base_class_
FACTORY_SETTINGS_CACHE = {}.freeze

FACTORY_SETTINGS_CACHE = {}
def initialize(factory_settings_, table_name_, name_, default_, sql_type_ = nil, null_ = true)
@factory_settings = factory_settings_
@table_name = table_name_
Expand Down