Skip to content

Commit

Permalink
Merge pull request #122 from zendesk/jury.razumau/rails71_rc2
Browse files Browse the repository at this point in the history
Add compatibility with ActiveRecord 7.1.0
  • Loading branch information
razumau authored Nov 21, 2023
2 parents e1fdaeb + 2cdd91a commit 1e307a8
Show file tree
Hide file tree
Showing 21 changed files with 411 additions and 53 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

tests:
runs-on: ubuntu-latest
name: rake test Gemfile ${{ matrix.gemfile }} and Ruby ${{ matrix.ruby-version }} (LCH ${{ matrix.legacy_connection_handling }})
name: Test ${{ matrix.gemfile }} with Ruby ${{ matrix.ruby-version }} (LCH ${{ matrix.legacy_connection_handling }})
services:
mysql:
image: mysql:5.7
Expand All @@ -40,9 +40,14 @@ jobs:
- rails6.1
- rails7.0_mysql2
- rails7.0_trilogy
- rails7.1_mysql2
- rails7.1_trilogy
legacy_connection_handling:
- "false"
- "true"
exclude:
- {gemfile: rails7.1_mysql2, legacy_connection_handling: "true"}
- {gemfile: rails7.1_trilogy, legacy_connection_handling: "true"}
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
LEGACY_CONNECTION_HANDLING: "${{ matrix.legacy_connection_handling }}"
Expand Down
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ and as of v1.0.0 this project adheres to [Semantic Versioning](https://semver.or

## [Unreleased]

### Added
- Add support for Rails 7.1.
- `Trilogy` is now a supported MySQL database adapter. ActiveRecordHostPool no longer requires `mysql2`, nor does it explicitly require `activerecord-trilogy-adapter`. Applications using ARHP will now need to explicitly require one of these adapters in its gemfile. When using `activerecord-trilogy-adapter` also ensure that the `trilogy` gem is locked to `v2.5.0+`.

### Removed
- Remove `mysql2` as a direct dependency, test Rails 7.0 with `mysql2` and `activerecord-trilogy-adapter`.
- Remove support for Rails 5.1, 5.2, and 6.0.

Expand Down
2 changes: 1 addition & 1 deletion active_record_host_pool.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.7.0"

s.add_runtime_dependency("activerecord", ">= 6.1.0", "< 7.1")
s.add_runtime_dependency("activerecord", ">= 6.1.0", "< 7.2")
end
2 changes: 1 addition & 1 deletion gemfiles/rails6.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
active_record_host_pool (1.2.5)
activerecord (>= 6.1.0, < 7.1)
activerecord (>= 6.1.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails7.0_mysql2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
active_record_host_pool (1.2.5)
activerecord (>= 6.1.0, < 7.1)
activerecord (>= 6.1.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -39,8 +39,8 @@ GEM
parser (3.2.2.4)
ast (~> 2.4.1)
racc
phenix (1.1.0)
activerecord (>= 4.2, < 7.1)
phenix (1.2.0)
activerecord (>= 4.2, < 7.2)
bundler
pry (0.14.2)
coderay (~> 1.1)
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails7.0_trilogy.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
active_record_host_pool (1.2.5)
activerecord (>= 6.1.0, < 7.1)
activerecord (>= 6.1.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -41,8 +41,8 @@ GEM
parser (3.2.2.4)
ast (~> 2.4.1)
racc
phenix (1.1.0)
activerecord (>= 4.2, < 7.1)
phenix (1.2.0)
activerecord (>= 4.2, < 7.2)
bundler
pry (0.14.2)
coderay (~> 1.1)
Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails7.1_mysql2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec path: "../"

gem "activerecord", "~> 7.1.0"
gem "mysql2", "~> 0.5"

eval_gemfile "common.rb"
121 changes: 121 additions & 0 deletions gemfiles/rails7.1_mysql2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
PATH
remote: ..
specs:
active_record_host_pool (1.2.5)
activerecord (>= 6.1.0, < 7.2)

GEM
remote: https://rubygems.org/
specs:
activemodel (7.1.1)
activesupport (= 7.1.1)
activerecord (7.1.1)
activemodel (= 7.1.1)
activesupport (= 7.1.1)
timeout (>= 0.4.0)
activesupport (7.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.4)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
drb (2.1.1)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
method_source (1.0.0)
minitest (5.20.0)
minitest-fail-fast (0.1.0)
minitest (~> 5)
minitest-line (0.6.5)
minitest (~> 5.0)
minitest-mock_expectations (1.1.3)
mutex_m (0.1.2)
mysql2 (0.5.5)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
phenix (1.2.0)
activerecord (>= 4.2, < 7.2)
bundler
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.2)
rexml (3.2.6)
rubocop (1.56.4)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
standard (1.31.2)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.4)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.1)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
timeout (0.4.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)

PLATFORMS
ruby

DEPENDENCIES
active_record_host_pool!
activerecord (~> 7.1.0)
byebug
minitest (>= 5.10.0)
minitest-fail-fast
minitest-line
minitest-mock_expectations (~> 1.1.3)
mysql2 (~> 0.5)
phenix (>= 1.0.1)
pry-byebug (~> 3.9)
rake (>= 12.0.0)
standard

BUNDLED WITH
2.4.15
10 changes: 10 additions & 0 deletions gemfiles/rails7.1_trilogy.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec path: "../"

gem "activerecord", "~> 7.1.0"
gem "trilogy", ">= 2.5.0"

eval_gemfile "common.rb"
121 changes: 121 additions & 0 deletions gemfiles/rails7.1_trilogy.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
PATH
remote: ..
specs:
active_record_host_pool (1.2.5)
activerecord (>= 6.1.0, < 7.2)

GEM
remote: https://rubygems.org/
specs:
activemodel (7.1.1)
activesupport (= 7.1.1)
activerecord (7.1.1)
activemodel (= 7.1.1)
activesupport (= 7.1.1)
timeout (>= 0.4.0)
activesupport (7.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.4)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
drb (2.1.1)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
method_source (1.0.0)
minitest (5.20.0)
minitest-fail-fast (0.1.0)
minitest (~> 5)
minitest-line (0.6.5)
minitest (~> 5.0)
minitest-mock_expectations (1.1.3)
mutex_m (0.1.2)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
phenix (1.2.0)
activerecord (>= 4.2, < 7.2)
bundler
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.2)
rexml (3.2.6)
rubocop (1.56.4)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
standard (1.31.2)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.4)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.1)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
timeout (0.4.0)
trilogy (2.6.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)

PLATFORMS
ruby

DEPENDENCIES
active_record_host_pool!
activerecord (~> 7.1.0)
byebug
minitest (>= 5.10.0)
minitest-fail-fast
minitest-line
minitest-mock_expectations (~> 1.1.3)
phenix (>= 1.0.1)
pry-byebug (~> 3.9)
rake (>= 12.0.0)
standard
trilogy (>= 2.5.0)

BUNDLED WITH
2.4.15
15 changes: 8 additions & 7 deletions lib/active_record_host_pool.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# frozen_string_literal: true

require "active_record"
require "active_record/base"
require "active_record/connection_adapters/abstract_adapter"

module ActiveRecordHostPool
class << self
attr_accessor :loaded_db_adapter
end
end

begin
if Gem.loaded_specs.include?("mysql2")
require "mysql2"
ActiveRecordHostPool.loaded_db_adapter = :mysql2
rescue LoadError
require "activerecord-trilogy-adapter"
elsif Gem.loaded_specs.include?("trilogy")
require "trilogy"
require "activerecord-trilogy-adapter" if ActiveRecord.version < Gem::Version.new("7.1")
ActiveRecordHostPool.loaded_db_adapter = :trilogy
end

require "active_record"
require "active_record/base"
require "active_record/connection_adapters/abstract_adapter"

require "active_record_host_pool/clear_query_cache_patch"
require "active_record_host_pool/connection_proxy"
require "active_record_host_pool/pool_proxy"
Expand Down
Loading

0 comments on commit 1e307a8

Please sign in to comment.