From 6597ebb5d6efd448ceae3c85db84761dcaf83a78 Mon Sep 17 00:00:00 2001 From: Tristan Starck Date: Wed, 23 Oct 2024 10:36:44 -0700 Subject: [PATCH 1/3] add support for rails 7.0 --- .github/workflows/build.yml | 1 + Appraisals | 2 +- Gemfile.lock | 16 ++++++++-------- fibered_mysql2.gemspec | 2 +- gemfiles/rails_7_0.gemfile | 16 ++++++++++++++++ .../fibered_mysql2_adapter.rb | 2 -- .../fibered_database_connection_pool.rb | 2 -- lib/fibered_mysql2/version.rb | 2 +- .../fibered_database_connection_pool_spec.rb | 4 +++- 9 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 gemfiles/rails_7_0.gemfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a98497..9f6681a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ jobs: - Gemfile - gemfiles/rails_6_0.gemfile - gemfiles/rails_6_1.gemfile + - gemfiles/rails_7_0.gemfile env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: diff --git a/Appraisals b/Appraisals index 92e0829..90f2173 100644 --- a/Appraisals +++ b/Appraisals @@ -2,4 +2,4 @@ require "appraisal/matrix" -appraisal_matrix(rails: "~> 6.0") +appraisal_matrix(rails: [">= 6.0", "< 7.1"]) diff --git a/Gemfile.lock b/Gemfile.lock index 6f760a8..595796c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ PATH remote: . specs: - fibered_mysql2 (1.0.1) + fibered_mysql2 (1.1.0) async - rails (>= 6, < 7) + rails (>= 6, < 7.1) GEM remote: https://rubygems.org/ @@ -73,7 +73,7 @@ GEM thor (>= 0.14.0) appraisal-matrix (0.3.0) appraisal (~> 2.2) - async (2.15.3) + async (2.17.0) console (~> 1.26) fiber-annotation io-event (~> 1.6, >= 1.6.5) @@ -103,9 +103,9 @@ GEM fiber-storage (1.0.0) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) - io-event (1.6.5) + io-event (1.7.3) json (2.7.2) loofah (2.22.0) crass (~> 1.0.2) @@ -121,7 +121,7 @@ GEM mini_portile2 (2.8.7) minitest (5.25.1) mysql2 (0.5.6) - net-imap (0.4.14) + net-imap (0.5.0) date net-protocol net-pop (0.1.2) @@ -141,7 +141,7 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) racc (1.8.1) - rack (2.2.9) + rack (2.2.10) rack-test (2.1.0) rack (>= 1.3) rails (6.1.7.8) @@ -211,7 +211,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.17) + zeitwerk (2.6.18) PLATFORMS ruby diff --git a/fibered_mysql2.gemspec b/fibered_mysql2.gemspec index 375ee69..6e6fbf4 100644 --- a/fibered_mysql2.gemspec +++ b/fibered_mysql2.gemspec @@ -30,5 +30,5 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency 'async' - spec.add_dependency 'rails', '>= 6', '< 7' + spec.add_dependency 'rails', '>= 6', '< 7.1' end diff --git a/gemfiles/rails_7_0.gemfile b/gemfiles/rails_7_0.gemfile new file mode 100644 index 0000000..5fd8832 --- /dev/null +++ b/gemfiles/rails_7_0.gemfile @@ -0,0 +1,16 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "appraisal-matrix" +gem "coveralls", require: false +gem "mysql2", "~> 0.5" +gem "nokogiri" +gem "pry" +gem "pry-byebug" +gem "rake" +gem "rspec" +gem "rails", "~> 7.0.0" + +gemspec path: "../" diff --git a/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb b/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb index 4b69022..ebe7355 100644 --- a/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb @@ -61,8 +61,6 @@ def owner_fiber end class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter - ActiveRecord::VERSION::MAJOR == 6 or raise ArgumentError, "unexpected Rails version #{ActiveRecord::VERSION::MAJOR}" - include FiberedMysql2Adapter_6 def initialize(*args) diff --git a/lib/fibered_mysql2/fibered_database_connection_pool.rb b/lib/fibered_mysql2/fibered_database_connection_pool.rb index 35043ec..3e4f9fb 100644 --- a/lib/fibered_mysql2/fibered_database_connection_pool.rb +++ b/lib/fibered_mysql2/fibered_database_connection_pool.rb @@ -4,8 +4,6 @@ module FiberedMysql2 module FiberedDatabaseConnectionPool - ActiveRecord::VERSION::MAJOR == 6 or raise ArgumentError, "unexpected Rails version #{ActiveRecord::VERSION::MAJOR}" - def cached_connections @thread_cached_conns end diff --git a/lib/fibered_mysql2/version.rb b/lib/fibered_mysql2/version.rb index b9384a6..7bf75e6 100644 --- a/lib/fibered_mysql2/version.rb +++ b/lib/fibered_mysql2/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module FiberedMysql2 - VERSION = "1.0.1" + VERSION = "1.1.0" end diff --git a/spec/unit/fibered_database_connection_pool_spec.rb b/spec/unit/fibered_database_connection_pool_spec.rb index f0844df..f5ba48b 100644 --- a/spec/unit/fibered_database_connection_pool_spec.rb +++ b/spec/unit/fibered_database_connection_pool_spec.rb @@ -272,8 +272,10 @@ def wait(task) let(:spec) do if ActiveRecord.gem_version < "6.1" ActiveRecord::ConnectionAdapters::ConnectionSpecification.new(name, config, adapter_method) - else + elsif ActiveRecord.gem_version < "7.0" ActiveRecord::ConnectionAdapters::PoolConfig.new(name, ActiveRecord::DatabaseConfigurations::HashConfig.new("staging", "staging", config)) + else + ActiveRecord::ConnectionAdapters::PoolConfig.new(name, ActiveRecord::DatabaseConfigurations::HashConfig.new("staging", "staging", config), "primary", nil) end end From 65465af10fa7c805d3be1790c115cdf6510fe164 Mon Sep 17 00:00:00 2001 From: Tristan Starck Date: Wed, 23 Oct 2024 10:39:45 -0700 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c48fad..2dce459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.0] - Unreleased +### Added +- Support for Rails 7.0 + ## [1.0.1] - 2024-08-19 ### Fixed - Fixed issues in Rails 6.1+ From a0fe982a9b8764164c3938fe8c10bd1a48ebbadc Mon Sep 17 00:00:00 2001 From: Tristan Starck Date: Wed, 23 Oct 2024 16:57:19 -0700 Subject: [PATCH 3/3] update changelog and readme --- CHANGELOG.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dce459..e49a2cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.1.0] - Unreleased +## [1.1.0] - 2024-10-23 ### Added - Support for Rails 7.0 diff --git a/README.md b/README.md index 8852cf8..9bdd0df 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ # FiberedMysql2 -FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::Mysql2Adapter` for Rails 6. -This is a stop-gap until Rails 7, which adds `isolation_level: :fiber` to `ActiveRecord`. +FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::Mysql2Adapter` for Rails versions < `7.1`. +This is a stop-gap until Rails 7.1, which adds `isolation_level: :fiber` to `ActiveRecord` connection pooling. ## Installation