activerecord-mysql2rgeo-adapter 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ae61ad75e0c3b01f1fcb7b01a1646c415126fbe
4
- data.tar.gz: f61144159cbcc55ade3b14bf0d52b7f843571ea4
3
+ metadata.gz: 3a35cacf27708b88079361795afb35a4673ceb7c
4
+ data.tar.gz: af091d82862dabd35ebeaf824402ff41549d0250
5
5
  SHA512:
6
- metadata.gz: 166a724c80d6d2c7ff032fec44a0954a9f463b673c6c36611b9b42c9532920d8e37ac004a7fe65730eef98445d9433bea12331be90654242e622148caa8fe879
7
- data.tar.gz: 45b5b5326a89185c8554ad234881188173ded6e01c9e8511dc82b4931583bbe27ccd0ef69b28fac7ef2f2d76dd4ff41bf678abea55ad1e1eb9ec77b439d3dffe
6
+ metadata.gz: 6a3c6341b3d00589d31a4fddb8a8cbbbbfa0f20a411fedf02f48953f8cdb81fcc7b90617e1f4e00a38440927208f76487d5758138c2994fac2a751340cf767a4
7
+ data.tar.gz: 30c1d75c52971c065ff6f39c37dd015cd40781a7638bba5eb5ee86607d5fd3c2da73b3bceded05a681ca966922d11d2516d766834904d1f11cf0b94bb2522d54
@@ -44,8 +44,8 @@ module ActiveRecord
44
44
  alias multi_linestring multilinestring
45
45
  alias multi_polygon multipolygon
46
46
  end
47
-
48
- MySQL::Table.send(:include, ColumnMethods)
49
47
  end
48
+
49
+ MySQL::Table.include Mysql2Rgeo::ColumnMethods
50
50
  end
51
51
  end
@@ -4,8 +4,8 @@ else
4
4
  require "mysql2"
5
5
  end
6
6
 
7
- module ActiveRecord # :nodoc:
8
- module ConnectionHandling # :nodoc:
7
+ module ActiveRecord # :nodoc:
8
+ module ConnectionHandling # :nodoc:
9
9
  if RUBY_ENGINE == "jruby"
10
10
 
11
11
  def jdbcmysql2rgeo_connection(config)
@@ -8,16 +8,12 @@ module ActiveRecord
8
8
  end
9
9
 
10
10
  def type_to_sql(type, limit = nil, precision = nil, scale = nil, array = nil)
11
- if (info = spatial_column_constructor(type.to_sym))
11
+ if (info = RGeo::ActiveRecord.geometric_type_from_name(type.to_s.delete("_")))
12
12
  type = limit[:type] || type if limit.is_a?(::Hash)
13
13
  type = "geometry" if type.to_s == "spatial"
14
14
  type = type.to_s.delete("_").upcase
15
15
  end
16
- super(type, limit, precision, scale, array)
17
- end
18
-
19
- def spatial_column_constructor(name)
20
- RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name]
16
+ super
21
17
  end
22
18
 
23
19
  # override
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module Mysql2Rgeo
4
- VERSION = "1.0.4".freeze
4
+ VERSION = "1.0.5".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -3,15 +3,22 @@
3
3
 
4
4
  # :stopdoc:
5
5
 
6
- require "active_record/connection_adapters/mysql2_adapter"
7
6
  require "rgeo/active_record"
7
+
8
+ # autoload AbstractAdapter to avoid circular require and void context warnings
9
+ module ActiveRecord
10
+ module ConnectionAdapters
11
+ AbstractAdapter
12
+ end
13
+ end
14
+
15
+ require "active_record/connection_adapters/mysql2_adapter"
8
16
  require "active_record/connection_adapters/mysql2rgeo/version"
9
17
  require "active_record/connection_adapters/mysql2rgeo/column_methods"
10
18
  require "active_record/connection_adapters/mysql2rgeo/schema_statements"
11
19
  require "active_record/connection_adapters/mysql2rgeo/spatial_table_definition"
12
20
  require "active_record/connection_adapters/mysql2rgeo/spatial_column"
13
21
  require "active_record/connection_adapters/mysql2rgeo/spatial_expressions"
14
- require "arel/visitors/bind_visitor"
15
22
  require "active_record/connection_adapters/mysql2rgeo/arel_tosql"
16
23
  require "active_record/type/spatial"
17
24
  require "active_record/connection_adapters/mysql2rgeo/create_connection"
@@ -39,8 +46,6 @@ module ActiveRecord
39
46
  # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
40
47
  DEFAULT_SRID = 0
41
48
 
42
- ADAPTER_NAME = "Mysql2Rgeo".freeze
43
-
44
49
  def initialize(connection, logger, connection_options, config)
45
50
  super
46
51
 
@@ -48,6 +53,10 @@ module ActiveRecord
48
53
  @visitor.extend(DetermineIfPreparableVisitor) if self.class.type_cast_config_to_boolean(config.fetch(:prepared_statements) { true })
49
54
  end
50
55
 
56
+ def adapter_name
57
+ "Mysql2Rgeo".freeze
58
+ end
59
+
51
60
  def self.spatial_column_options(key)
52
61
  SPATIAL_COLUMN_OPTIONS[key]
53
62
  end
@@ -22,9 +22,9 @@ module ActiveRecord
22
22
  def self.parse_sql_type(sql_type)
23
23
  geo_type, srid, has_z, has_m = nil, 0, false, false
24
24
 
25
- if sql_type =~ /[geography,geometry]\((.*)\)$/i
25
+ if sql_type =~ /(geography|geometry)\((.*)\)$/i
26
26
  # geometry(Point,4326)
27
- params = Regexp.last_match(1).split(",")
27
+ params = Regexp.last_match(2).split(",")
28
28
  if params.size > 1
29
29
  if params.first =~ /([a-z]+[^zm])(z?)(m?)/i
30
30
  has_z = !Regexp.last_match(2).empty?
@@ -45,25 +45,25 @@ module ActiveRecord
45
45
  [geo_type, srid, has_z, has_m]
46
46
  end
47
47
 
48
- def klass
49
- type == :geometry ? RGeo::Feature::Geometry : super
48
+ def spatial_factory
49
+ @spatial_factory ||=
50
+ RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
51
+ geo_type: @geo_type,
52
+ sql_type: @sql_type,
53
+ srid: @srid
54
+ )
50
55
  end
51
56
 
52
- def type
53
- :geometry
57
+ def klass
58
+ type == :geometry ? RGeo::Feature::Geometry : super
54
59
  end
55
60
 
56
61
  def spatial?
57
62
  true
58
63
  end
59
64
 
60
- def spatial_factory
61
- @spatial_factory ||=
62
- RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
63
- geo_type: @geo_type,
64
- sql_type: @sql_type,
65
- srid: @srid
66
- )
65
+ def type
66
+ :geometry
67
67
  end
68
68
 
69
69
  # support setting an RGeo object or a WKT string
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: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yongdae Hwang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.0.0
33
+ version: '6.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.0.0
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.6.10
137
+ rubygems_version: 2.6.13
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: ActiveRecord adapter for MySQL, based on RGeo.