activerecord-mysql2rgeo-adapter 5.2.2 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff6faa5bd2d1fdbd11d39ae470198df22169779733a6a2edfb07bdb316cf8101
4
- data.tar.gz: 1466bc545f7d632a47934022ec1ee16755b3d32d92d7b9fb5e470abefd4858ef
3
+ metadata.gz: 58d333c713e0bd75f678bd8fb11812edeeccab83beded3b36bc14a25cd0c4f20
4
+ data.tar.gz: 49365cad5609ac644e6d2e9ae1727576c2aa321caf350ca95a2e05bd3689cbdb
5
5
  SHA512:
6
- metadata.gz: 923e9ea973d64cf7503114ce25a88dca5fb1419d9fddad878579a124270a26a7fca55e02364bae8c5822a8d8160635a581539d2b525c3d90bd6bce417f9e8681
7
- data.tar.gz: 7fa56cefbadc3afeeb5558f86b6a349adf725eca130bba822a7012e8bd95da0c04ba849501ae950cb34788dab52d9933b096099bc4ba414435b4f0712a0ad176
6
+ metadata.gz: fd02b75e6df3f66ecb3ad82ea531c8ea3d25e5a4d0747a0d8154dc157060330ff9e62ce9da2ef36ee195ce45a9c30d39c6026e07eac7cd0bfb8ec0bba8be297f
7
+ data.tar.gz: 4a5ac24de947e2877bbd1c7bbd105cd80aef155a4759867b31639150294a81236fcfd119d1bc8d8752e27fe2ffff3f34459a745afc9e27a36897a4acb6eacfe6
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Arel # :nodoc:
4
- module Visitors # :nodoc:
3
+ module Arel # :nodoc:
4
+ module Visitors # :nodoc:
5
5
  # Different super-class under JRuby JDBC adapter.
6
6
  MySQLSuperclass = if defined?(::ArJdbc::MySQL::BindSubstitution)
7
7
  ::ArJdbc::MySQL::BindSubstitution
@@ -27,12 +27,55 @@ module Arel # :nodoc:
27
27
  end
28
28
 
29
29
  def visit_String(node, collector)
30
- collector << "#{st_func('ST_WKTToSQL')}(#{quote(node)})"
30
+ node, srid = Mysql2Rgeo.parse_node(node)
31
+ collector << if srid == 0
32
+ "#{st_func('ST_WKTToSQL')}(#{quote(node)})"
33
+ else
34
+ "#{st_func('ST_WKTToSQL')}(#{quote(node)}, #{srid})"
35
+ end
31
36
  end
32
37
 
33
38
  def visit_RGeo_ActiveRecord_SpatialNamedFunction(node, collector)
34
39
  aggregate(st_func(node.name), node, collector)
35
40
  end
41
+
42
+ def visit_in_spatial_context(node, collector)
43
+ case node
44
+ when String
45
+ node, srid = Mysql2Rgeo.parse_node(node)
46
+ collector << if srid == 0
47
+ "#{st_func('ST_WKTToSQL')}(#{quote(node)})"
48
+ else
49
+ "#{st_func('ST_WKTToSQL')}(#{quote(node)}, #{srid})"
50
+ end
51
+ when RGeo::Feature::Instance
52
+ collector << visit_RGeo_Feature_Instance(node, collector)
53
+ when RGeo::Cartesian::BoundingBox
54
+ collector << visit_RGeo_Cartesian_BoundingBox(node, collector)
55
+ else
56
+ visit(node, collector)
57
+ end
58
+ end
59
+
60
+ def self.parse_node(node)
61
+ value, srid = nil, 0
62
+ if node =~ /.*;.*$/i
63
+ params = Regexp.last_match(0).split(";")
64
+ if params.first =~ /(srid|SRID)=\d*/
65
+ srid = params.first.split("=").last.to_i
66
+ else
67
+ value = params.first
68
+ end
69
+ if params.last =~ /(srid|SRID)=\d*/
70
+ srid = params.last.split("=").last.to_i
71
+ else
72
+ value = params.last
73
+ end
74
+ else
75
+ value = node
76
+ end
77
+ [value, srid]
78
+ end
36
79
  end
37
80
  end
38
81
  end
@@ -6,44 +6,45 @@ module ActiveRecord
6
6
  module ColumnMethods
7
7
  def spatial(name, options = {})
8
8
  raise "You must set a type. For example: 't.spatial type: :st_point'" unless options[:type]
9
- column(name, options[:type], options)
9
+
10
+ column(name, options[:type], **options)
10
11
  end
11
12
 
12
13
  def geometry(name, options = {})
13
- column(name, :geometry, options)
14
+ column(name, :geometry, **options)
14
15
  end
15
16
 
16
17
  def geometry_collection(name, options = {})
17
- column(name, :geometrycollection, options)
18
+ column(name, :geometrycollection, **options)
18
19
  end
19
20
  alias geometrycollection geometry_collection
20
21
 
21
22
  def line_string(name, options = {})
22
- column(name, :linestring, options)
23
+ column(name, :linestring, **options)
23
24
  end
24
25
  alias linestring line_string
25
26
 
26
27
  def multi_line_string(name, options = {})
27
- column(name, :multilinestring, options)
28
+ column(name, :multilinestring, **options)
28
29
  end
29
30
  alias multilinestring multi_line_string
30
31
 
31
32
  def multi_point(name, options = {})
32
- column(name, :multipoint, options)
33
+ column(name, :multipoint, **options)
33
34
  end
34
35
  alias multipoint multi_point
35
36
 
36
37
  def multi_polygon(name, options = {})
37
- column(name, :multipolygon, options)
38
+ column(name, :multipolygon, **options)
38
39
  end
39
40
  alias multipolygon multi_polygon
40
41
 
41
42
  def point(name, options = {})
42
- column(name, :point, options)
43
+ column(name, :point, **options)
43
44
  end
44
45
 
45
46
  def polygon(name, options = {})
46
- column(name, :polygon, options)
47
+ column(name, :polygon, **options)
47
48
  end
48
49
  end
49
50
  end
@@ -15,7 +15,7 @@ module ActiveRecord # :nodoc:
15
15
  mysql2_connection(config)
16
16
  end
17
17
 
18
- alias_method :jdbcmysql2rgeo_connection, :mysql2rgeo_connection
18
+ alias jdbcmysql2rgeo_connection mysql2rgeo_connection
19
19
 
20
20
  else
21
21
 
@@ -39,8 +39,8 @@ module ActiveRecord # :nodoc:
39
39
 
40
40
  client = Mysql2::Client.new(config)
41
41
  ConnectionAdapters::Mysql2RgeoAdapter.new(client, logger, nil, config)
42
- rescue Mysql2::Error => error
43
- if error.message.include?("Unknown database")
42
+ rescue Mysql2::Error => e
43
+ if e.message.include?("Unknown database")
44
44
  raise ActiveRecord::NoDatabaseError
45
45
  else
46
46
  raise
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module Mysql2Rgeo
6
+ class SchemaCreation < MySQL::SchemaCreation # :nodoc:
7
+ delegate :supports_expression_index?, to: :@conn, private: true
8
+
9
+ private
10
+
11
+ def add_column_options!(sql, options)
12
+ # By default, TIMESTAMP columns are NOT NULL, cannot contain NULL values,
13
+ # and assigning NULL assigns the current timestamp. To permit a TIMESTAMP
14
+ # column to contain NULL, explicitly declare it with the NULL attribute.
15
+ # See https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html
16
+ if /\Atimestamp\b/.match?(options[:column].sql_type) && !options[:primary_key]
17
+ sql << " NULL" unless options[:null] == false || options_include_default?(options)
18
+ end
19
+
20
+ if options[:srid]
21
+ sql << " /*!80003 SRID #{options[:srid]} */"
22
+ end
23
+
24
+ if charset = options[:charset]
25
+ sql << " CHARACTER SET #{charset}"
26
+ end
27
+
28
+ if collation = options[:collation]
29
+ sql << " COLLATE #{collation}"
30
+ end
31
+
32
+ if as = options[:as]
33
+ sql << " AS (#{as})"
34
+ if options[:stored]
35
+ sql << (mariadb? ? " PERSISTENT" : " STORED")
36
+ end
37
+ end
38
+
39
+ add_sql_comment!(super, options[:comment])
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -4,15 +4,20 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module Mysql2Rgeo
6
6
  module SchemaStatements
7
+ # super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
8
+
7
9
  # override
8
10
  def indexes(table_name) #:nodoc:
9
11
  indexes = super
10
12
  # HACK(aleks, 06/15/18): MySQL 5 does not support prefix lengths for spatial indexes
11
13
  # https://dev.mysql.com/doc/refman/5.6/en/create-index.html
12
- indexes.select { |idx| idx.type == :spatial }.each { |idx| idx.is_a?(Struct) ? idx.lengths = {} : idx.instance_variable_set(:@lengths, {}) }
14
+ indexes.select do |idx|
15
+ idx.type == :spatial
16
+ end.each { |idx| idx.is_a?(Struct) ? idx.lengths = {} : idx.instance_variable_set(:@lengths, {}) }
13
17
  indexes
14
18
  end
15
19
 
20
+ # override
16
21
  def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
17
22
  if (info = RGeo::ActiveRecord.geometric_type_from_name(type.to_s.delete("_")))
18
23
  type = limit[:type] || type if limit.is_a?(::Hash)
@@ -40,7 +45,8 @@ module ActiveRecord
40
45
 
41
46
  def initialize_type_map(m = type_map)
42
47
  super
43
- %w(
48
+
49
+ %w[
44
50
  geometry
45
51
  geometrycollection
46
52
  point
@@ -49,38 +55,57 @@ module ActiveRecord
49
55
  multipoint
50
56
  multilinestring
51
57
  multipolygon
52
- ).each do |geo_type|
53
- m.register_type(geo_type, Type::Spatial.new(geo_type))
58
+ ].each do |geo_type|
59
+ m.register_type(geo_type) do |sql_type|
60
+ Type::Spatial.new(sql_type)
61
+ end
54
62
  end
55
63
  end
56
64
 
57
65
  private
58
66
 
59
67
  # override
60
- def create_table_definition(*args)
61
- Mysql2Rgeo::TableDefinition.new(*args)
68
+ def schema_creation
69
+ Mysql2Rgeo::SchemaCreation.new(self)
70
+ end
71
+
72
+ # override
73
+ def create_table_definition(*args, **options)
74
+ Mysql2Rgeo::TableDefinition.new(self, *args, **options)
62
75
  end
63
76
 
64
77
  # override
65
78
  def new_column_from_field(table_name, field)
66
79
  type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
67
- if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(field[:Default])
68
- default, default_function = nil, field[:Default]
69
- else
70
- default, default_function = field[:Default], nil
80
+ default, default_function = field[:Default], nil
81
+
82
+ if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default)
83
+ default, default_function = nil, default
84
+ elsif type_metadata.extra == "DEFAULT_GENERATED"
85
+ default = +"(#{default})" unless default.start_with?("(")
86
+ default, default_function = nil, default
71
87
  end
72
88
 
89
+ # {:dimension=>2, :has_m=>false, :has_z=>false, :name=>"latlon", :srid=>0, :type=>"GEOMETRY"}
90
+ spatial = spatial_column_info(table_name).get(field[:Field], type_metadata.sql_type)
91
+
73
92
  SpatialColumn.new(
74
- field[:Field],
75
- default,
76
- type_metadata,
77
- field[:Null] == "YES",
78
- table_name,
79
- default_function,
80
- field[:Collation],
81
- comment: field[:Comment].presence
93
+ field[:Field],
94
+ default,
95
+ type_metadata,
96
+ field[:Null] == "YES",
97
+ default_function,
98
+ collation: field[:Collation],
99
+ comment: field[:Comment].presence,
100
+ spatial: spatial
82
101
  )
83
102
  end
103
+
104
+ # memoize hash of column infos for tables
105
+ def spatial_column_info(table_name)
106
+ @spatial_column_info ||= {}
107
+ @spatial_column_info[table_name.to_sym] = SpatialColumnInfo.new(self, table_name.to_s)
108
+ end
84
109
  end
85
110
  end
86
111
  end
@@ -1,21 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord # :nodoc:
2
4
  module ConnectionAdapters # :nodoc:
3
5
  module Mysql2Rgeo # :nodoc:
4
6
  class SpatialColumn < ConnectionAdapters::MySQL::Column # :nodoc:
5
- def initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil)
6
- @geometric_type = nil
7
- if sql_type =~ /geometry|point|linestring|polygon/i
7
+ def initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil, spatial: nil, **)
8
+ @sql_type_metadata = sql_type_metadata
9
+ if spatial
10
+ # This case comes from an entry in the geometry_columns table
11
+ set_geometric_type_from_name(spatial[:type])
12
+ @srid = spatial[:srid].to_i
13
+ elsif sql_type =~ /geometry|point|linestring|polygon/i
8
14
  build_from_sql_type(sql_type_metadata.sql_type)
9
15
  elsif sql_type_metadata.sql_type =~ /geometry|point|linestring|polygon/i
10
16
  # A geometry column with no geometry_columns entry.
11
17
  # @geometric_type = geo_type_from_sql_type(sql_type)
12
18
  build_from_sql_type(sql_type_metadata.sql_type)
13
19
  end
14
- super(name, default, sql_type_metadata, null, table_name, default_function, collation, comment: comment)
20
+ super(name, default, sql_type_metadata, null, default_function, collation: collation, comment: comment)
15
21
  if spatial?
16
22
  if @srid
17
- @limit = { type: @geometric_type.type_name.underscore }
18
- @limit[:srid] = @srid if @srid
23
+ @limit = { type: @geometric_type.type_name.underscore, srid: @srid }
19
24
  end
20
25
  end
21
26
  end
@@ -34,9 +39,9 @@ module ActiveRecord # :nodoc:
34
39
  false
35
40
  end
36
41
 
37
- alias :geographic? :geographic
38
- alias :has_z? :has_z
39
- alias :has_m? :has_m
42
+ alias geographic? geographic
43
+ alias has_z? has_z
44
+ alias has_m? has_m
40
45
 
41
46
  def limit
42
47
  if spatial?
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord # :nodoc:
4
+ module ConnectionAdapters # :nodoc:
5
+ module Mysql2Rgeo # :nodoc:
6
+ # Do spatial sql queries for column info and memoize that info.
7
+ class SpatialColumnInfo
8
+ def initialize(adapter, table_name)
9
+ @adapter = adapter
10
+ @table_name = table_name
11
+ end
12
+
13
+ def all
14
+ info = if @adapter.supports_expression_index?
15
+ @adapter.query(
16
+ "SELECT column_name, srs_id, column_type FROM INFORMATION_SCHEMA.Columns WHERE table_name='#{@table_name}'"
17
+ )
18
+ else
19
+ @adapter.query(
20
+ "SELECT column_name, 0, column_type FROM INFORMATION_SCHEMA.Columns WHERE table_name='#{@table_name}'"
21
+ )
22
+ end
23
+
24
+ result = {}
25
+ info.each do |row|
26
+ name = row[0]
27
+ type = row[2]
28
+ type.sub!(/m$/, "")
29
+ result[name] = {
30
+ name: name,
31
+ srid: row[1].to_i,
32
+ type: type,
33
+ }
34
+ end
35
+ result
36
+ end
37
+
38
+ # do not query the database for non-spatial columns/tables
39
+ def get(column_name, type)
40
+ return unless Mysql2RgeoAdapter.spatial_column_options(type.to_sym)
41
+
42
+ @spatial_column_info ||= all
43
+ @spatial_column_info[column_name]
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RGeo
2
4
  module ActiveRecord
3
5
  module Mysql2Rgeo
@@ -13,6 +15,6 @@ module RGeo
13
15
  end
14
16
 
15
17
  # Allow chaining of spatial expressions from attributes
16
- Arel::Attribute.send :include, RGeo::ActiveRecord::Mysql2Rgeo::SpatialExpressions
17
- RGeo::ActiveRecord::SpatialConstantNode.send :include, RGeo::ActiveRecord::Mysql2Rgeo::SpatialExpressions
18
- RGeo::ActiveRecord::SpatialNamedFunction.send :include, RGeo::ActiveRecord::Mysql2Rgeo::SpatialExpressions
18
+ Arel::Attribute.include RGeo::ActiveRecord::Mysql2Rgeo::SpatialExpressions
19
+ RGeo::ActiveRecord::SpatialConstantNode.include RGeo::ActiveRecord::Mysql2Rgeo::SpatialExpressions
20
+ RGeo::ActiveRecord::SpatialNamedFunction.include RGeo::ActiveRecord::Mysql2Rgeo::SpatialExpressions
@@ -1,22 +1,23 @@
1
- module ActiveRecord # :nodoc:
2
- module ConnectionAdapters # :nodoc:
3
- module Mysql2Rgeo # :nodoc:
4
- class TableDefinition < MySQL::TableDefinition # :nodoc:
5
- include ColumnMethods
1
+ # frozen_string_literal: true
6
2
 
3
+ module ActiveRecord # :nodoc:
4
+ module ConnectionAdapters # :nodoc:
5
+ module Mysql2Rgeo # :nodoc:
6
+ class TableDefinition < MySQL::TableDefinition # :nodoc:
7
+ include ColumnMethods
7
8
  # super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
8
- def new_column_definition(name, type, options)
9
+ def new_column_definition(name, type, **options)
9
10
  if (info = Mysql2RgeoAdapter.spatial_column_options(type.to_sym))
10
- if (limit = options.delete(:limit))
11
- options.merge!(limit) if limit.is_a?(::Hash)
11
+ if (limit = options.delete(:limit)) && limit.is_a?(::Hash)
12
+ options.merge!(limit)
12
13
  end
13
14
 
14
15
  geo_type = ColumnDefinitionUtils.geo_type(options[:type] || type || info[:type])
15
16
 
16
17
  options[:spatial_type] = geo_type
17
- column = super(name, geo_type.downcase.to_sym, options)
18
+ column = super(name, geo_type.downcase.to_sym, **options)
18
19
  else
19
- column = super(name, type, options)
20
+ column = super(name, type, **options)
20
21
  end
21
22
 
22
23
  column
@@ -26,7 +27,7 @@ module ActiveRecord # :nodoc:
26
27
  module ColumnDefinitionUtils
27
28
  class << self
28
29
  def geo_type(type = "GEOMETRY")
29
- type.to_s.delete('_').upcase
30
+ type.to_s.delete("_").upcase
30
31
  end
31
32
 
32
33
  def default_srid(options)
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module Mysql2Rgeo
6
- VERSION = "5.2.2"
6
+ VERSION = "6.0.2"
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -17,9 +17,11 @@ end
17
17
  require "active_record/connection_adapters/mysql2_adapter"
18
18
  require "active_record/connection_adapters/mysql2rgeo/version"
19
19
  require "active_record/connection_adapters/mysql2rgeo/column_methods"
20
+ require "active_record/connection_adapters/mysql2rgeo/schema_creation"
20
21
  require "active_record/connection_adapters/mysql2rgeo/schema_statements"
21
22
  require "active_record/connection_adapters/mysql2rgeo/spatial_table_definition"
22
23
  require "active_record/connection_adapters/mysql2rgeo/spatial_column"
24
+ require "active_record/connection_adapters/mysql2rgeo/spatial_column_info"
23
25
  require "active_record/connection_adapters/mysql2rgeo/spatial_expressions"
24
26
  require "active_record/connection_adapters/mysql2rgeo/arel_tosql"
25
27
  require "active_record/type/spatial"
@@ -43,7 +45,7 @@ module ActiveRecord
43
45
  spatial: { type: "geometry" },
44
46
  point: {},
45
47
  polygon: {}
46
- }
48
+ }.freeze
47
49
 
48
50
  # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
49
51
  DEFAULT_SRID = 0
@@ -21,7 +21,6 @@ module ActiveRecord
21
21
  # srid: 1234
22
22
  def self.parse_sql_type(sql_type)
23
23
  geo_type, srid = nil, 0, false, false
24
-
25
24
  if sql_type =~ /(geography|geometry)\((.*)\)$/i
26
25
  # geometry(Point)
27
26
  # geometry(Point,4326)
@@ -42,11 +41,11 @@ module ActiveRecord
42
41
 
43
42
  def spatial_factory
44
43
  @spatial_factory ||=
45
- RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
46
- geo_type: @geo_type,
47
- sql_type: @sql_type,
48
- srid: @srid
49
- )
44
+ RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
45
+ geo_type: @geo_type,
46
+ sql_type: @sql_type,
47
+ srid: @srid
48
+ )
50
49
  end
51
50
 
52
51
  def klass
@@ -64,11 +63,13 @@ module ActiveRecord
64
63
  # support setting an RGeo object or a WKT string
65
64
  def serialize(value)
66
65
  return if value.nil?
66
+
67
67
  geo_value = cast_value(value)
68
68
 
69
- # TODO - only valid types should be allowed
69
+ # TODO: - only valid types should be allowed
70
70
  # e.g. linestring is not valid for point column
71
71
  raise "maybe should raise" unless RGeo::Feature::Geometry.check_type(geo_value)
72
+
72
73
  geo_value
73
74
  end
74
75
 
@@ -76,22 +77,25 @@ module ActiveRecord
76
77
 
77
78
  def cast_value(value)
78
79
  return if value.nil?
80
+
79
81
  ::String === value ? parse_wkt(value) : value
80
82
  end
81
83
 
84
+ # convert WKT string into RGeo object
82
85
  def parse_wkt(string)
83
86
  marker = string[4, 1]
84
- if marker == "\x00" || marker == "\x01"
85
- srid = string[0, 4].unpack(marker == "\x01" ? "V" : "N").first
86
- RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: srid).parse(string[4..-1])
87
+ if ["\x00", "\x01"].include?(marker)
88
+ @srid = string[0, 4].unpack1(marker == "\x01" ? "V" : "N")
89
+ RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: @srid).parse(string[4..-1])
87
90
  elsif string[0, 10] =~ /[0-9a-fA-F]{8}0[01]/
88
- srid = string[0, 8].to_i(16)
89
- srid = [srid].pack("V").unpack("N").first if string[9, 1] == "1"
91
+ @srid = string[0, 8].to_i(16)
92
+ @srid = [@srid].pack("V").unpack("N").first if string[9, 1] == "1"
90
93
  RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: srid).parse(string[8..-1])
91
94
  else
95
+ string, @srid = Arel::Visitors::Mysql2Rgeo.parse_node(string)
92
96
  RGeo::WKRep::WKTParser.new(spatial_factory, support_ewkt: true, default_srid: @srid).parse(string)
93
97
  end
94
- rescue RGeo::Error::ParseError
98
+ rescue RGeo::Error::ParseError, RGeo::Error::InvalidGeometry
95
99
  nil
96
100
  end
97
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql2rgeo-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.2
4
+ version: 6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yongdae Hwang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2021-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.1'
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.1'
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rgeo-activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '12.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -106,8 +106,10 @@ files:
106
106
  - lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb
107
107
  - lib/active_record/connection_adapters/mysql2rgeo/column_methods.rb
108
108
  - lib/active_record/connection_adapters/mysql2rgeo/create_connection.rb
109
+ - lib/active_record/connection_adapters/mysql2rgeo/schema_creation.rb
109
110
  - lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb
110
111
  - lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb
112
+ - lib/active_record/connection_adapters/mysql2rgeo/spatial_column_info.rb
111
113
  - lib/active_record/connection_adapters/mysql2rgeo/spatial_expressions.rb
112
114
  - lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb
113
115
  - lib/active_record/connection_adapters/mysql2rgeo/version.rb
@@ -116,7 +118,7 @@ files:
116
118
  - lib/activerecord-mysql2rgeo-adapter.rb
117
119
  homepage: http://github.com/stadia/activerecord-mysql2rgeo-adapter
118
120
  licenses:
119
- - BSD
121
+ - BSD-3-Clause
120
122
  metadata: {}
121
123
  post_install_message:
122
124
  rdoc_options: []
@@ -126,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
128
  requirements:
127
129
  - - ">="
128
130
  - !ruby/object:Gem::Version
129
- version: 2.2.2
131
+ version: 2.5.0
130
132
  required_rubygems_version: !ruby/object:Gem::Requirement
131
133
  requirements:
132
134
  - - ">="