activerecord-mysql2rgeo-adapter 7.3.1 → 7.3.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 +4 -4
- data/lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb +4 -6
- data/lib/active_record/connection_adapters/mysql2rgeo/schema_creation.rb +21 -22
- data/lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb +10 -11
- data/lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb +9 -9
- data/lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb +18 -12
- data/lib/active_record/connection_adapters/mysql2rgeo/version.rb +1 -1
- data/lib/active_record/connection_adapters/mysql2rgeo_adapter.rb +55 -54
- data/lib/active_record/type/spatial.rb +5 -7
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 816dbf40bdc492a42c20ded6aef4f247a76dedbbdd73bc6d705a400f8b8cfdc7
|
|
4
|
+
data.tar.gz: 4a04ba14c239948df20572c8b29a13f4c6296dfc11edb3beba35b1b76c26124f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dce6e73f2b2f93d1cdd543e6c30e305adf20135faec080f0361a00f1b7f95d34556ac51e4d98fdaa41c565674db4444353529b06b413ac708cf2b0c6750600e
|
|
7
|
+
data.tar.gz: 2d697dc4767e38740316346fd727dcf352ab1bc41340b4a45ec4c15a3f73f0e1742ba3dc70c0af231aca6f5d091e5d87f9c17b2d6f96493625bc00a3c275ddbd
|
|
@@ -9,12 +9,10 @@ module Arel # :nodoc:
|
|
|
9
9
|
MySQL
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
class Mysql2Rgeo < MySQLSuperclass
|
|
12
|
+
class Mysql2Rgeo < MySQLSuperclass # :nodoc:
|
|
13
13
|
include RGeo::ActiveRecord::SpatialToSql
|
|
14
14
|
|
|
15
|
-
if ::Arel::Visitors.const_defined?(:BindVisitor)
|
|
16
|
-
include ::Arel::Visitors::BindVisitor
|
|
17
|
-
end
|
|
15
|
+
include ::Arel::Visitors::BindVisitor if ::Arel::Visitors.const_defined?(:BindVisitor)
|
|
18
16
|
|
|
19
17
|
FUNC_MAP = {
|
|
20
18
|
"st_wkttosql" => "ST_GeomFromText",
|
|
@@ -52,12 +50,12 @@ module Arel # :nodoc:
|
|
|
52
50
|
end
|
|
53
51
|
|
|
54
52
|
def self.parse_node(node)
|
|
55
|
-
if RGeo::Feature::Instance
|
|
53
|
+
if node.is_a?(RGeo::Feature::Instance)
|
|
56
54
|
wkt = RGeo::WKRep::WKTGenerator.new(tag_format: :wkt11, emit_ewkt_srid: false).generate(node)
|
|
57
55
|
return [wkt, node.srid]
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
if RGeo::Cartesian::BoundingBox
|
|
58
|
+
if node.is_a?(RGeo::Cartesian::BoundingBox)
|
|
61
59
|
geometry = node.to_geometry
|
|
62
60
|
wkt = RGeo::WKRep::WKTGenerator.new(tag_format: :wkt11, emit_ewkt_srid: false).generate(geometry)
|
|
63
61
|
return [wkt, geometry.srid]
|
|
@@ -5,34 +5,33 @@ module ActiveRecord
|
|
|
5
5
|
module Mysql2Rgeo
|
|
6
6
|
class SchemaCreation < MySQL::SchemaCreation # :nodoc:
|
|
7
7
|
private
|
|
8
|
-
def visit_IndexDefinition(o, create = false)
|
|
9
|
-
if o.using&.to_sym == :gist
|
|
10
|
-
sql = create ? ["CREATE SPATIAL INDEX"] : ["SPATIAL INDEX"]
|
|
11
|
-
sql << quote_column_name(o.name)
|
|
12
|
-
sql << "ON #{quote_table_name(o.table)}" if create
|
|
13
|
-
sql << "(#{quoted_columns(o)})"
|
|
14
|
-
return sql.join(" ")
|
|
15
|
-
end
|
|
16
8
|
|
|
17
|
-
|
|
9
|
+
def visit_IndexDefinition(o, create = false)
|
|
10
|
+
if o.using&.to_sym == :gist
|
|
11
|
+
sql = create ? ["CREATE SPATIAL INDEX"] : ["SPATIAL INDEX"]
|
|
12
|
+
sql << quote_column_name(o.name)
|
|
13
|
+
sql << "ON #{quote_table_name(o.table)}" if create
|
|
14
|
+
sql << "(#{quoted_columns(o)})"
|
|
15
|
+
return sql.join(" ")
|
|
18
16
|
end
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
sql << " /*!80003 SRID #{options[:srid]} */"
|
|
23
|
-
options = options.except(:srid)
|
|
24
|
-
end
|
|
18
|
+
super
|
|
19
|
+
end
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
super
|
|
21
|
+
def add_column_options!(sql, options)
|
|
22
|
+
if options[:srid]
|
|
23
|
+
sql << " /*!80003 SRID #{options[:srid]} */"
|
|
24
|
+
options = options.except(:srid)
|
|
31
25
|
end
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
options = options.except(:default) if options_include_default?(options) && spatial_column_definition?(options[:column])
|
|
28
|
+
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def spatial_column_definition?(column)
|
|
33
|
+
column.respond_to?(:type) && column.type && @conn.class.spatial_column_options(column.type.to_sym)
|
|
34
|
+
end
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
37
|
end
|
|
@@ -7,7 +7,7 @@ module ActiveRecord
|
|
|
7
7
|
# super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
|
|
8
8
|
|
|
9
9
|
# override
|
|
10
|
-
def indexes(table_name)
|
|
10
|
+
def indexes(table_name) # :nodoc:
|
|
11
11
|
indexes = super
|
|
12
12
|
# HACK(aleks, 06/15/18): MySQL 5 does not support prefix lengths for spatial indexes
|
|
13
13
|
# https://dev.mysql.com/doc/refman/5.6/en/create-index.html
|
|
@@ -33,7 +33,7 @@ module ActiveRecord
|
|
|
33
33
|
|
|
34
34
|
column_options = column.limit.is_a?(Hash) ? column.limit.symbolize_keys.except(:type) : {}
|
|
35
35
|
column_options[:comment] = column.comment if column.comment.present?
|
|
36
|
-
change_column(table_name, name, column.limit[:type].to_sym, **column_options
|
|
36
|
+
change_column(table_name, name, column.limit[:type].to_sym, **column_options, null: false)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -42,11 +42,9 @@ module ActiveRecord
|
|
|
42
42
|
|
|
43
43
|
# override
|
|
44
44
|
def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
|
|
45
|
-
if type.to_sym == :geometry && limit.is_a?(String)
|
|
46
|
-
return "geometry(#{limit})"
|
|
47
|
-
end
|
|
45
|
+
return "geometry(#{limit})" if type.to_sym == :geometry && limit.is_a?(String)
|
|
48
46
|
|
|
49
|
-
if
|
|
47
|
+
if RGeo::ActiveRecord.geometric_type_from_name(type.to_s.delete("_"))
|
|
50
48
|
type = limit[:type] || type if limit.is_a?(::Hash)
|
|
51
49
|
type = type.to_s.delete("_").upcase
|
|
52
50
|
end
|
|
@@ -87,7 +85,7 @@ module ActiveRecord
|
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
if default&.match?(/\Ast_geomfromtext\(/i)
|
|
90
|
-
default =
|
|
88
|
+
default = "(#{default})" unless default.start_with?("(")
|
|
91
89
|
default, default_function = nil, default
|
|
92
90
|
end
|
|
93
91
|
end
|
|
@@ -116,9 +114,9 @@ module ActiveRecord
|
|
|
116
114
|
type: :geometry,
|
|
117
115
|
limit: nil,
|
|
118
116
|
precision: type_metadata.precision,
|
|
119
|
-
scale: type_metadata.scale
|
|
117
|
+
scale: type_metadata.scale
|
|
120
118
|
),
|
|
121
|
-
extra: type_metadata.extra
|
|
119
|
+
extra: type_metadata.extra
|
|
122
120
|
)
|
|
123
121
|
|
|
124
122
|
if default_function&.match?(/\A\(?st_geomfromtext\(/i)
|
|
@@ -159,10 +157,11 @@ module ActiveRecord
|
|
|
159
157
|
srid: srid,
|
|
160
158
|
geographic: spatial[:geographic],
|
|
161
159
|
has_z: spatial[:has_z],
|
|
162
|
-
has_m: spatial[:has_m]
|
|
160
|
+
has_m: spatial[:has_m]
|
|
163
161
|
)
|
|
164
162
|
geometry = type.serialize(wkt)
|
|
165
163
|
return unless geometry
|
|
164
|
+
|
|
166
165
|
geometry = RGeo::Feature.cast(geometry, factory: type.send(:spatial_factory), project: true) if spatial[:geographic]
|
|
167
166
|
|
|
168
167
|
wkb = RGeo::WKRep::WKBGenerator.new(
|
|
@@ -185,7 +184,7 @@ module ActiveRecord
|
|
|
185
184
|
AND table_name = #{quote(table_name)}
|
|
186
185
|
AND column_name = #{quote(column_name)}
|
|
187
186
|
SQL
|
|
188
|
-
|
|
187
|
+
&.gsub(/st_buffer\(([^,]+),\s*(\d+)\)/i, 'st_buffer(\1, (\2)::double precision)')
|
|
189
188
|
end
|
|
190
189
|
|
|
191
190
|
def generated_default_for(table_name, column_name)
|
|
@@ -4,7 +4,8 @@ module ActiveRecord # :nodoc:
|
|
|
4
4
|
module ConnectionAdapters # :nodoc:
|
|
5
5
|
module Mysql2Rgeo # :nodoc:
|
|
6
6
|
class SpatialColumn < ConnectionAdapters::MySQL::Column # :nodoc:
|
|
7
|
-
def initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil,
|
|
7
|
+
def initialize(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil,
|
|
8
|
+
spatial: nil, array: false, **)
|
|
8
9
|
@sql_type_metadata = sql_type_metadata
|
|
9
10
|
@array = array
|
|
10
11
|
if spatial
|
|
@@ -22,14 +23,13 @@ module ActiveRecord # :nodoc:
|
|
|
22
23
|
build_from_sql_type(sql_type_metadata.sql_type)
|
|
23
24
|
end
|
|
24
25
|
super(name, default, sql_type_metadata, null, default_function, collation: collation, comment: comment)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
26
|
+
return unless spatial?
|
|
27
|
+
return unless @srid
|
|
28
|
+
|
|
29
|
+
@limit = { type: limit_type_name, srid: @srid }
|
|
30
|
+
@limit[:geographic] = true if geographic?
|
|
31
|
+
@limit[:has_z] = true if has_z?
|
|
32
|
+
@limit[:has_m] = true if has_m?
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
attr_reader :geometric_type, :srid
|
|
@@ -5,6 +5,7 @@ module ActiveRecord # :nodoc:
|
|
|
5
5
|
module Mysql2Rgeo # :nodoc:
|
|
6
6
|
class TableDefinition < MySQL::TableDefinition # :nodoc:
|
|
7
7
|
include ColumnMethods
|
|
8
|
+
|
|
8
9
|
# super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
|
|
9
10
|
def new_column_definition(name, type, **options)
|
|
10
11
|
spatial_type = type.to_sym == :virtual ? options[:type]&.to_sym : type.to_sym
|
|
@@ -20,7 +21,9 @@ module ActiveRecord # :nodoc:
|
|
|
20
21
|
ColumnDefinitionUtils.geo_type(options[:type] || spatial_type || info[:type])
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
if type.to_sym == :virtual
|
|
25
|
+
options.delete(:srid)
|
|
26
|
+
else
|
|
24
27
|
options[:srid] ||= ColumnDefinitionUtils.default_srid(options)
|
|
25
28
|
options[:comment] = ColumnDefinitionUtils.add_metadata_comment(
|
|
26
29
|
options[:comment],
|
|
@@ -32,19 +35,20 @@ module ActiveRecord # :nodoc:
|
|
|
32
35
|
srid: options[:srid],
|
|
33
36
|
geo_type: geo_type
|
|
34
37
|
)
|
|
35
|
-
else
|
|
36
|
-
options.delete(:srid)
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
options[:spatial_type] = geo_type
|
|
40
|
-
if type.to_sym == :virtual
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
column = if type.to_sym == :virtual
|
|
42
|
+
super(name, type, **options.merge(type: geo_type.downcase.to_sym))
|
|
43
|
+
else
|
|
44
|
+
super(name, geo_type.downcase.to_sym, **options)
|
|
45
|
+
end
|
|
45
46
|
else
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
if options[:array]
|
|
48
|
+
options[:comment] =
|
|
49
|
+
ColumnDefinitionUtils.add_metadata_comment(options[:comment], array: options[:array])
|
|
50
|
+
end
|
|
51
|
+
column = super
|
|
48
52
|
end
|
|
49
53
|
|
|
50
54
|
column
|
|
@@ -77,14 +81,16 @@ module ActiveRecord # :nodoc:
|
|
|
77
81
|
options[:geographic] ? 4326 : Mysql2RgeoAdapter::DEFAULT_SRID
|
|
78
82
|
end
|
|
79
83
|
|
|
80
|
-
def add_metadata_comment(comment, geographic: false, has_m: false, has_z: false, array: false, default: nil, srid: nil,
|
|
84
|
+
def add_metadata_comment(comment, geographic: false, has_m: false, has_z: false, array: false, default: nil, srid: nil,
|
|
85
|
+
geo_type: nil)
|
|
81
86
|
values = [comment]
|
|
82
87
|
values << METADATA_TOKENS[:geographic] if geographic
|
|
83
88
|
values << METADATA_TOKENS[:has_m] if has_m
|
|
84
89
|
values << METADATA_TOKENS[:has_z] if has_z
|
|
85
90
|
values << METADATA_TOKENS[:array] if array
|
|
86
91
|
if default
|
|
87
|
-
values << "#{METADATA_TOKENS[:default_prefix]}#{encode_default(default, geographic: geographic, srid: srid,
|
|
92
|
+
values << "#{METADATA_TOKENS[:default_prefix]}#{encode_default(default, geographic: geographic, srid: srid,
|
|
93
|
+
geo_type: geo_type, has_m: has_m, has_z: has_z)}"
|
|
88
94
|
end
|
|
89
95
|
values.compact_blank.join(" ")
|
|
90
96
|
end
|
|
@@ -29,7 +29,7 @@ module ActiveRecord
|
|
|
29
29
|
config = config.symbolize_keys
|
|
30
30
|
config[:flags] ||= 0
|
|
31
31
|
|
|
32
|
-
if config[:flags].
|
|
32
|
+
if config[:flags].is_a? Array
|
|
33
33
|
config[:flags].push "FOUND_ROWS"
|
|
34
34
|
else
|
|
35
35
|
config[:flags] |= Mysql2::Client::FOUND_ROWS
|
|
@@ -39,7 +39,7 @@ module ActiveRecord
|
|
|
39
39
|
ConnectionAdapters::Mysql2RgeoAdapter.new_client(config),
|
|
40
40
|
logger,
|
|
41
41
|
nil,
|
|
42
|
-
config
|
|
42
|
+
config
|
|
43
43
|
)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -110,61 +110,61 @@ module ActiveRecord
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
class << self
|
|
113
|
-
|
|
114
113
|
private
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
114
|
+
|
|
115
|
+
def initialize_type_map(m)
|
|
116
|
+
super
|
|
117
|
+
|
|
118
|
+
{
|
|
119
|
+
"geography" => "geometry",
|
|
120
|
+
"geometry" => "geometry",
|
|
121
|
+
"geometry_collection" => "geometrycollection",
|
|
122
|
+
"line_string" => "linestring",
|
|
123
|
+
"multi_line_string" => "multilinestring",
|
|
124
|
+
"multi_point" => "multipoint",
|
|
125
|
+
"multi_polygon" => "multipolygon",
|
|
126
|
+
"st_point" => "point",
|
|
127
|
+
"st_polygon" => "polygon",
|
|
128
|
+
}.each do |registered_type, geo_type|
|
|
129
|
+
m.register_type(registered_type) do |sql_type|
|
|
130
|
+
Type::Spatial.new(sql_type.to_s, geo_type: geo_type)
|
|
132
131
|
end
|
|
132
|
+
end
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
end
|
|
134
|
+
[
|
|
135
|
+
/\Ageometry(?:\(.*\))?\z/i,
|
|
136
|
+
/\Ageography(?:\(.*\))?\z/i,
|
|
137
|
+
/\Apoint(?:\s.*)?\z/i,
|
|
138
|
+
/\Alinestring(?:\s.*)?\z/i,
|
|
139
|
+
/\Apolygon(?:\s.*)?\z/i,
|
|
140
|
+
/\Amultipoint(?:\s.*)?\z/i,
|
|
141
|
+
/\Amultilinestring(?:\s.*)?\z/i,
|
|
142
|
+
/\Amultipolygon(?:\s.*)?\z/i,
|
|
143
|
+
/\Ageometrycollection(?:\s.*)?\z/i,
|
|
144
|
+
].each do |pattern|
|
|
145
|
+
m.register_type(pattern) do |sql_type|
|
|
146
|
+
Type::Spatial.new(sql_type.to_s)
|
|
148
147
|
end
|
|
148
|
+
end
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
end
|
|
150
|
+
{
|
|
151
|
+
st_point: "point",
|
|
152
|
+
st_polygon: "polygon",
|
|
153
|
+
line_string: "linestring",
|
|
154
|
+
multi_line_string: "multilinestring",
|
|
155
|
+
multi_point: "multipoint",
|
|
156
|
+
multi_polygon: "multipolygon",
|
|
157
|
+
}.each do |alias_type, geo_type|
|
|
158
|
+
ActiveRecord::Type.register(alias_type) do |_, **kwargs|
|
|
159
|
+
Type::Spatial.new(geo_type, geo_type: geo_type, **kwargs)
|
|
161
160
|
end
|
|
162
161
|
end
|
|
162
|
+
end
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
TYPE_MAP = Type::TypeMap.new.tap { |m| initialize_type_map(m) }
|
|
166
166
|
TYPE_MAP_WITH_BOOLEAN = Type::TypeMap.new(TYPE_MAP).tap do |m|
|
|
167
|
-
m.register_type
|
|
167
|
+
m.register_type(/^tinyint\(1\)/i, Type::Boolean.new)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
def supports_spatial?
|
|
@@ -203,16 +203,17 @@ module ActiveRecord
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
private
|
|
206
|
-
def verify_supported_database_version!
|
|
207
|
-
return if database_version >= MINIMUM_SUPPORTED_VERSION
|
|
208
206
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
end
|
|
207
|
+
def verify_supported_database_version!
|
|
208
|
+
return if database_version >= MINIMUM_SUPPORTED_VERSION
|
|
212
209
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
raise ActiveRecord::ConnectionNotEstablished,
|
|
211
|
+
"#{ADAPTER_NAME} supports MySQL #{MINIMUM_SUPPORTED_VERSION}+ only (detected #{database_version})"
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def type_map
|
|
215
|
+
emulate_booleans ? TYPE_MAP_WITH_BOOLEAN : TYPE_MAP
|
|
216
|
+
end
|
|
216
217
|
end
|
|
217
218
|
end
|
|
218
219
|
end
|
|
@@ -41,9 +41,7 @@ module ActiveRecord
|
|
|
41
41
|
has_z = Regexp.last_match(2).casecmp("z").zero?
|
|
42
42
|
has_m = Regexp.last_match(3).casecmp("m").zero?
|
|
43
43
|
end
|
|
44
|
-
if params.last =~ /(\d+)/
|
|
45
|
-
srid = Regexp.last_match(1).to_i
|
|
46
|
-
end
|
|
44
|
+
srid = Regexp.last_match(1).to_i if params.last =~ /(\d+)/
|
|
47
45
|
elsif sql_type =~ /\A(geography|geometry)\z/i
|
|
48
46
|
geographic = Regexp.last_match(1).casecmp("geography").zero?
|
|
49
47
|
geo_type = Regexp.last_match(1)
|
|
@@ -82,7 +80,7 @@ module ActiveRecord
|
|
|
82
80
|
has_z: @has_z,
|
|
83
81
|
sql_type: @geographic ? "geography" : "geometry",
|
|
84
82
|
srid: @srid
|
|
85
|
-
|
|
83
|
+
)
|
|
86
84
|
end
|
|
87
85
|
|
|
88
86
|
def klass
|
|
@@ -118,7 +116,7 @@ module ActiveRecord
|
|
|
118
116
|
def cast_value(value)
|
|
119
117
|
return if value.nil?
|
|
120
118
|
|
|
121
|
-
::String
|
|
119
|
+
value.is_a?(::String) ? parse_wkt(value) : value
|
|
122
120
|
end
|
|
123
121
|
|
|
124
122
|
# convert WKT string into RGeo object
|
|
@@ -126,7 +124,7 @@ module ActiveRecord
|
|
|
126
124
|
marker = string[4, 1]
|
|
127
125
|
if ["\x00", "\x01"].include?(marker)
|
|
128
126
|
@srid = string[0, 4].unpack1(marker == "\x01" ? "V" : "N")
|
|
129
|
-
RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: @srid).parse(string[4
|
|
127
|
+
RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: @srid).parse(string[4..])
|
|
130
128
|
elsif string.match?(/\A[0-9a-fA-F]+\z/)
|
|
131
129
|
original_srid = @srid
|
|
132
130
|
parser = RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: @srid)
|
|
@@ -141,7 +139,7 @@ module ActiveRecord
|
|
|
141
139
|
@srid = string[0, 8].to_i(16)
|
|
142
140
|
@srid = [@srid].pack("V").unpack("N").first if string[9, 1] == "1"
|
|
143
141
|
parser = RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: @srid)
|
|
144
|
-
return parser.parse([string[8
|
|
142
|
+
return parser.parse([string[8..]].pack("H*"))
|
|
145
143
|
end
|
|
146
144
|
|
|
147
145
|
parser.parse([string].pack("H*"))
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-mysql2rgeo-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.3.
|
|
4
|
+
version: 7.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yongdae Hwang
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -137,7 +136,6 @@ metadata:
|
|
|
137
136
|
source_code_uri: https://github.com/stadia/activerecord-mysql2rgeo-adapter
|
|
138
137
|
documentation_uri: https://github.com/stadia/activerecord-mysql2rgeo-adapter/blob/main/README.md
|
|
139
138
|
rubygems_mfa_required: 'true'
|
|
140
|
-
post_install_message:
|
|
141
139
|
rdoc_options: []
|
|
142
140
|
require_paths:
|
|
143
141
|
- lib
|
|
@@ -152,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
152
150
|
- !ruby/object:Gem::Version
|
|
153
151
|
version: '0'
|
|
154
152
|
requirements: []
|
|
155
|
-
rubygems_version:
|
|
156
|
-
signing_key:
|
|
153
|
+
rubygems_version: 4.0.20
|
|
157
154
|
specification_version: 4
|
|
158
155
|
summary: ActiveRecord adapter for MySQL, based on RGeo.
|
|
159
156
|
test_files: []
|