activerecord-mysql2rgeo-adapter 2.0.2 → 2.0.3

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
  SHA1:
3
- metadata.gz: ea97a0b53d1e086113d42b31c79ae3afe8595fef
4
- data.tar.gz: 8f292a2708c744814b8932113e88270192e6aefe
3
+ metadata.gz: 347e7b8819994c6d6759e88a5ab6af2b580650bd
4
+ data.tar.gz: 8e1aba30818aae96723909abb47da9f304cb7896
5
5
  SHA512:
6
- metadata.gz: 53725d357c6c360993a4a24ba9accd78f6e5fe18c961ad2492b8dacd967d72c2b905673f82b1504d80b760dd554cda7332c5cb0eaeb972d3c0161cdaaf3e78d9
7
- data.tar.gz: fd0da5355832e57506425040a2714f2eec7f482aa095aae1f55e67bfa6b711e93da8a078c895a3487f9db273819beefad7ad9db475ba16ef7b6c6d1d009dbbcc
6
+ metadata.gz: c91c8e58ceeef1a4d0482969d52df5abd15008b97580804ef7fde65a4dd6377b8d91f2adc289957d5ec5211ecc5c15862440412f6851d8efa7494c8ad8fd49ba
7
+ data.tar.gz: 9f772f1d2501e46e9cf7a0982ef73fa06809b17aad795e2ecb6e5307a3f538f1f2e56b904216ca2d50fb9f665e26d702716f0b8d3b11033a270d4fb75996f1b1
@@ -8,18 +8,14 @@ module ActiveRecord
8
8
  end
9
9
 
10
10
  def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
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
- type = 'geometry' if type.to_s.eql? 'spatial'
13
+ type = :geometry if type.eql? :spatial
14
14
  type = type.to_s.delete("_").upcase
15
15
  end
16
16
  super
17
17
  end
18
18
 
19
- def spatial_column_constructor(name)
20
- RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name]
21
- end
22
-
23
19
  # override
24
20
  def native_database_types
25
21
  # Add spatial types
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module Mysql2Rgeo
4
- VERSION = "2.0.2".freeze
4
+ VERSION = "2.0.3".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"
@@ -34,13 +41,11 @@ module ActiveRecord
34
41
  spatial: { type: "geometry" },
35
42
  point: {},
36
43
  polygon: {}
37
- }
44
+ }.freeze
38
45
 
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?
@@ -84,7 +84,7 @@ module ActiveRecord
84
84
  case value
85
85
  when ::RGeo::Feature::Geometry
86
86
  value
87
- # RGeo::Feature.cast(value, spatial_factory) rescue nil
87
+ # RGeo::Feature.cast(value, spatial_factory) rescue nil
88
88
  when ::String
89
89
  marker = value[4, 1]
90
90
  if marker == "\x00" || marker == "\x01"
@@ -109,7 +109,7 @@ module ActiveRecord
109
109
  nil
110
110
  end
111
111
  end
112
- end
112
+ end
113
113
  end
114
114
  end
115
115
  end
@@ -1 +1 @@
1
- require "active_record/connection_adapters/mysql2rgeo_adapter.rb"
1
+ require "active_record/connection_adapters/mysql2rgeo_adapter"
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: 2.0.2
4
+ version: 2.0.3
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-11-08 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
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rgeo-activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "<"
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.1.1
33
+ version: '5.1'
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.1.1
40
+ version: '5.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement