diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b66e5f..0cdfd63 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,9 +19,9 @@ jobs: BUNDLE_GEMFILE: ${{matrix.gemfile}} strategy: matrix: - ruby: ['3.0', '2.7'] + ruby: ['3.1', '2.7'] gemfile: - - gemfiles/ar71.gemfile + - gemfiles/ar72.gemfile mysql: ['5.7', '8.0'] steps: - name: Set Up Actions diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 93a1fdd..d4a3762 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,7 +13,7 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' - - 'gemfiles/ar71.gemfile' + - 'gemfiles/ar72.gemfile' # Offense count: 2 # Cop supports --auto-correct. diff --git a/.travis.yml b/.travis.yml index 8956fe0..f6395b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ rvm: - jruby-9.2.6.0 - 3.0 gemfile: - - gemfiles/ar71.gemfile + - gemfiles/ar72.gemfile matrix: allow_failures: - rvm: jruby-9.2.6.0 diff --git a/Appraisals b/Appraisals index b90c4fd..42f8abb 100644 --- a/Appraisals +++ b/Appraisals @@ -1,3 +1,3 @@ -appraise "ar71" do - gem "activerecord", "~> 7.1.0" +appraise "ar72" do + gem "activerecord", "~> 7.2.0" end diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7389b5a..b749493 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,8 +41,8 @@ Run tests against the test gemfiles: run `rake appraisal` or run the tests manually: ``` -BUNDLE_GEMFILE=./gemfiles/ar71.gemfile bundle -BUNDLE_GEMFILE=./gemfiles/ar71.gemfile rake +BUNDLE_GEMFILE=./gemfiles/ar72.gemfile bundle +BUNDLE_GEMFILE=./gemfiles/ar72.gemfile rake ``` Make your changes and submit a pull request. diff --git a/activerecord-mysql2rgeo-adapter.gemspec b/activerecord-mysql2rgeo-adapter.gemspec index 58a397b..0c05432 100644 --- a/activerecord-mysql2rgeo-adapter.gemspec +++ b/activerecord-mysql2rgeo-adapter.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7.0" - spec.add_dependency "activerecord", "~> 7.1.0" + spec.add_dependency "activerecord", "~> 7.2.0" spec.add_dependency "rgeo-activerecord", "~> 7.0.0" spec.add_dependency "rgeo", "~> 2.0" diff --git a/gemfiles/ar71.gemfile b/gemfiles/ar72.gemfile similarity index 89% rename from gemfiles/ar71.gemfile rename to gemfiles/ar72.gemfile index 038114d..f0e4862 100644 --- a/gemfiles/ar71.gemfile +++ b/gemfiles/ar72.gemfile @@ -6,6 +6,6 @@ gem "mysql2", "~> 0.5.2", platform: :ruby gem "jdbc-mysql", platform: :jruby gem "activerecord-jdbc-adapter", "~> 5.0", platform: :jruby gem "ffi-geos", platform: :jruby -gem "activerecord", "~> 7.1.0" +gem "activerecord", "~> 7.2.0" gemspec path: "../" diff --git a/lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb b/lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb index d6fac8b..bdf7d32 100644 --- a/lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb +++ b/lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb @@ -22,6 +22,10 @@ def new_column_definition(name, type, **options) column end + + def valid_column_definition_options + super + %i[geographic has_m spatial_type srid] + end end module ColumnDefinitionUtils diff --git a/lib/active_record/connection_adapters/mysql2rgeo/version.rb b/lib/active_record/connection_adapters/mysql2rgeo/version.rb index e5207c1..453bcf9 100644 --- a/lib/active_record/connection_adapters/mysql2rgeo/version.rb +++ b/lib/active_record/connection_adapters/mysql2rgeo/version.rb @@ -3,7 +3,7 @@ module ActiveRecord module ConnectionAdapters module Mysql2Rgeo - VERSION = "7.1.0" + VERSION = "7.2.0" end end end diff --git a/lib/active_record/connection_adapters/mysql2rgeo_adapter.rb b/lib/active_record/connection_adapters/mysql2rgeo_adapter.rb index 00cacc4..1909b23 100644 --- a/lib/active_record/connection_adapters/mysql2rgeo_adapter.rb +++ b/lib/active_record/connection_adapters/mysql2rgeo_adapter.rb @@ -66,7 +66,7 @@ class Mysql2RgeoAdapter < Mysql2Adapter # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html DEFAULT_SRID = 0 - def initialize(connection, logger, connection_options, config) + def initialize(...) super @visitor = Arel::Visitors::Mysql2Rgeo.new(self) @@ -137,6 +137,10 @@ def quote(value) end end + def with_connection + yield self + end + private def type_map emulate_booleans ? TYPE_MAP_WITH_BOOLEAN : TYPE_MAP diff --git a/lib/activerecord-mysql2rgeo-adapter.rb b/lib/activerecord-mysql2rgeo-adapter.rb index 8c80577..2fdf871 100644 --- a/lib/activerecord-mysql2rgeo-adapter.rb +++ b/lib/activerecord-mysql2rgeo-adapter.rb @@ -1,3 +1,5 @@ # frozen_string_literal: true require "active_record/connection_adapters/mysql2rgeo_adapter" + +ActiveRecord::ConnectionAdapters.register('mysql2rgeo', 'ActiveRecord::ConnectionAdapters::Mysql2RgeoAdapter', 'active_record/connection_adapters/mysql2rgeo_adapter') diff --git a/test/basic_test.rb b/test/basic_test.rb index 42039ed..f705862 100644 --- a/test/basic_test.rb +++ b/test/basic_test.rb @@ -134,7 +134,7 @@ def test_point_to_json obj = SpatialModel.new assert_match(/"latlon":null/, obj.to_json) obj.latlon = factory.point(1.0, 2.0) - assert_match(/"latlon":"POINT\s\(1\.0\s2\.0\)"/, obj.to_json) + assert_match(/"latlon":"POINT\s\(1(\.0)?\s2(\.0)?\)"/, obj.to_json) end def test_custom_column