Skip to content

Commit

Permalink
add support for rails 7.0 (#14)
Browse files Browse the repository at this point in the history
* add support for rails 7.0
  • Loading branch information
ttstarck authored Oct 24, 2024
1 parent 4be02e6 commit 268e73f
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

require "appraisal/matrix"

appraisal_matrix(rails: "~> 6.0")
appraisal_matrix(rails: [">= 6.0", "< 7.1"])
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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] - 2024-10-23
### Added
- Support for Rails 7.0

## [1.0.1] - 2024-08-19
### Fixed
- Fixed issues in Rails 6.1+
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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/
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion fibered_mysql2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions lib/fibered_mysql2/fibered_database_connection_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/fibered_mysql2/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module FiberedMysql2
VERSION = "1.0.1"
VERSION = "1.1.0"
end
4 changes: 3 additions & 1 deletion spec/unit/fibered_database_connection_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 268e73f

Please sign in to comment.