activerecord-mysql2rgeo-adapter 6.0.3 → 6.1.1

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
  SHA256:
3
- metadata.gz: 609c9daa90d73fa24300948060c080d5e75f38e63163fdff0ed15e8ed8185126
4
- data.tar.gz: 141ea30c5e86b4c5dd6e86b6779343d063d377a2d51fb5f87bc68446f3bf34a3
3
+ metadata.gz: fc08589944b261d0dca6908f375c8453eae76a29ff3da7a6c76f264fac0400dd
4
+ data.tar.gz: a3682118ef63d2605688f0f2c81713af2c58987a42f40425baff6f58326bf059
5
5
  SHA512:
6
- metadata.gz: 921929a8523f225a01db835ed7721d3bbc90f25ccce9eb99a74db9d708f07d81f65b331770b0d0e982d2b019906af4355086aa881cceb5424ec26b125d77ec88
7
- data.tar.gz: 46551aa0b6cb5cdf5debcc2a3e06de0e9a31c24c77bb3e2aca7a76dc54fcb9ea5710a2f90b66c7baac2911e50880a38dc9ff072de2470c7265110fbf81dcf01d
6
+ metadata.gz: 6a791e518607f77b3fa3affcca3402498d669d8011613c33e811db57278096382b87897a1477b8b18a66c4175ecd419ed161dd57a050b837b6e160943108158a
7
+ data.tar.gz: 03d6461ef1db07a0deedba7d5843bf6e9a4a00927de6f5e3b6c1ecf8834e1c95494d6ff03b56d0b08aeab675a4e39cea1e7623808507e5b4c62270f3e540a82f
@@ -4,15 +4,13 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module Mysql2Rgeo
6
6
  class SchemaCreation < MySQL::SchemaCreation # :nodoc:
7
- delegate :supports_expression_index?, to: :@conn, private: true
8
-
9
7
  private
10
8
 
11
9
  def add_column_options!(sql, options)
12
10
  # By default, TIMESTAMP columns are NOT NULL, cannot contain NULL values,
13
11
  # and assigning NULL assigns the current timestamp. To permit a TIMESTAMP
14
12
  # 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
13
+ # See https://dev.mysql.com/doc/refman/en/timestamp-initialization.html
16
14
  if /\Atimestamp\b/.match?(options[:column].sql_type) && !options[:primary_key]
17
15
  sql << " NULL" unless options[:null] == false || options_include_default?(options)
18
16
  end
@@ -20,7 +20,7 @@ module ActiveRecord # :nodoc:
20
20
  super(name, default, sql_type_metadata, null, default_function, collation: collation, comment: comment)
21
21
  if spatial?
22
22
  if @srid
23
- @limit = { type: @geometric_type.type_name.underscore, srid: @srid }
23
+ @limit = { type: geometric_type.type_name.underscore, srid: @srid }
24
24
  end
25
25
  end
26
26
  end
@@ -43,24 +43,16 @@ module ActiveRecord # :nodoc:
43
43
  alias has_z? has_z
44
44
  alias has_m? has_m
45
45
 
46
- def limit
47
- if spatial?
48
- @limit
49
- else
50
- super
51
- end
46
+ def multi?
47
+ /^(geometrycollection|multi)/i.match?(sql_type)
52
48
  end
53
49
 
54
- def klass
55
- type == :spatial ? RGeo::Feature::Geometry : super
50
+ def limit
51
+ spatial? ? @limit : super
56
52
  end
57
53
 
58
54
  def spatial?
59
- !@geometric_type.nil?
60
- end
61
-
62
- def multi?
63
- /^(geometrycollection|multi)/i.match?(sql_type)
55
+ %i[geometry geography].include?(@sql_type_metadata.type)
64
56
  end
65
57
 
66
58
  private
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module Mysql2Rgeo
6
- VERSION = "6.0.3"
6
+ VERSION = "6.1.1"
7
7
  end
8
8
  end
9
9
  end
@@ -7,13 +7,7 @@
7
7
 
8
8
  require "rgeo/active_record"
9
9
 
10
- # autoload AbstractAdapter to avoid circular require and void context warnings
11
- module ActiveRecord
12
- module ConnectionAdapters
13
- AbstractAdapter
14
- end
15
- end
16
-
10
+ require "active_record/connection_adapters"
17
11
  require "active_record/connection_adapters/mysql2_adapter"
18
12
  require "active_record/connection_adapters/mysql2rgeo/version"
19
13
  require "active_record/connection_adapters/mysql2rgeo/column_methods"
@@ -25,13 +19,35 @@ require "active_record/connection_adapters/mysql2rgeo/spatial_column_info"
25
19
  require "active_record/connection_adapters/mysql2rgeo/spatial_expressions"
26
20
  require "active_record/connection_adapters/mysql2rgeo/arel_tosql"
27
21
  require "active_record/type/spatial"
28
- require "active_record/connection_adapters/mysql2rgeo/create_connection"
29
22
 
30
23
  # :startdoc:
31
24
 
32
25
  module ActiveRecord
26
+ module ConnectionHandling # :nodoc:
27
+ # Establishes a connection to the database that's used by all Active Record objects.
28
+ def mysql2rgeo_connection(config)
29
+ config = config.symbolize_keys
30
+ config[:flags] ||= 0
31
+
32
+ if config[:flags].kind_of? Array
33
+ config[:flags].push "FOUND_ROWS"
34
+ else
35
+ config[:flags] |= Mysql2::Client::FOUND_ROWS
36
+ end
37
+
38
+ ConnectionAdapters::Mysql2RgeoAdapter.new(
39
+ ConnectionAdapters::Mysql2RgeoAdapter.new_client(config),
40
+ logger,
41
+ nil,
42
+ config,
43
+ )
44
+ end
45
+ end
46
+
33
47
  module ConnectionAdapters
34
48
  class Mysql2RgeoAdapter < Mysql2Adapter
49
+ ADAPTER_NAME = "Mysql2Rgeo"
50
+
35
51
  include Mysql2Rgeo::SchemaStatements
36
52
 
37
53
  SPATIAL_COLUMN_OPTIONS =
@@ -56,10 +72,6 @@ module ActiveRecord
56
72
  @visitor = Arel::Visitors::Mysql2Rgeo.new(self)
57
73
  end
58
74
 
59
- def adapter_name
60
- "Mysql2Rgeo"
61
- end
62
-
63
75
  def self.spatial_column_options(key)
64
76
  SPATIAL_COLUMN_OPTIONS[key]
65
77
  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: 6.0.3
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yongdae Hwang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-14 00:00:00.000000000 Z
11
+ date: 2022-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: '6.1'
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: 6.0.0
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
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: '6.0'
33
+ version: 7.0.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: '6.0'
40
+ version: 7.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '13.0'
47
+ version: '12.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: '13.0'
54
+ version: '12.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -105,7 +105,6 @@ files:
105
105
  - LICENSE.txt
106
106
  - lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb
107
107
  - lib/active_record/connection_adapters/mysql2rgeo/column_methods.rb
108
- - lib/active_record/connection_adapters/mysql2rgeo/create_connection.rb
109
108
  - lib/active_record/connection_adapters/mysql2rgeo/schema_creation.rb
110
109
  - lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb
111
110
  - lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb
@@ -120,7 +119,7 @@ homepage: http://github.com/stadia/activerecord-mysql2rgeo-adapter
120
119
  licenses:
121
120
  - BSD-3-Clause
122
121
  metadata: {}
123
- post_install_message:
122
+ post_install_message:
124
123
  rdoc_options: []
125
124
  require_paths:
126
125
  - lib
@@ -135,9 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
134
  - !ruby/object:Gem::Version
136
135
  version: '0'
137
136
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.7.6
140
- signing_key:
137
+ rubygems_version: 3.2.33
138
+ signing_key:
141
139
  specification_version: 4
142
140
  summary: ActiveRecord adapter for MySQL, based on RGeo.
143
141
  test_files: []
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if RUBY_ENGINE == "jruby"
4
- require "active_record/connection_adapters/jdbcmysql_adapter"
5
- else
6
- require "mysql2"
7
- end
8
-
9
- module ActiveRecord # :nodoc:
10
- module ConnectionHandling # :nodoc:
11
- if RUBY_ENGINE == "jruby"
12
-
13
- def jdbcmysql2rgeo_connection(config)
14
- config[:adapter_class] = ConnectionAdapters::Mysql2RgeoAdapter
15
- mysql2_connection(config)
16
- end
17
-
18
- alias jdbcmysql2rgeo_connection mysql2rgeo_connection
19
-
20
- else
21
-
22
- # Based on the default <tt>mysql2_connection</tt> definition from ActiveRecord.
23
- # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
24
- # FULL REPLACEMENT because we need to create a different class.
25
-
26
- def mysql2rgeo_connection(config)
27
- config = config.symbolize_keys
28
-
29
- config[:username] = "root" if config[:username].nil?
30
- config[:flags] ||= 0
31
-
32
- if Mysql2::Client.const_defined? :FOUND_ROWS
33
- if config[:flags].is_a? Array
34
- config[:flags].push "FOUND_ROWS"
35
- else
36
- config[:flags] |= Mysql2::Client::FOUND_ROWS
37
- end
38
- end
39
-
40
- client = Mysql2::Client.new(config)
41
- ConnectionAdapters::Mysql2RgeoAdapter.new(client, logger, nil, config)
42
- rescue Mysql2::Error => e
43
- if e.message.include?("Unknown database")
44
- raise ActiveRecord::NoDatabaseError
45
- else
46
- raise
47
- end
48
- end
49
- end
50
- end
51
- end