Skip to content

Commit 024f6c7

Browse files
authored
Rails 7.1/7.2 (#55)
1 parent c1e0763 commit 024f6c7

9 files changed

+46
-13
lines changed

.github/workflows/unit_tests.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@ name: Unit Tests
22
on:
33
pull_request:
44
branches:
5-
- '*'
5+
- "*"
66
push:
77
branches:
8-
- '*'
8+
- "master"
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
1414
include:
15-
- gemfile: gemfiles/rails_3.1.x.gemfile
16-
ruby-version: 2.2
17-
- gemfile: gemfiles/rails_3.2.x.gemfile
18-
ruby-version: 2.2
1915
- gemfile: gemfiles/rails_4.0.x.gemfile
2016
ruby-version: 2.3
2117
- gemfile: gemfiles/rails_4.1.x.gemfile
@@ -38,8 +34,14 @@ jobs:
3834
ruby-version: 3.0
3935
- gemfile: gemfiles/rails_7.0.x.gemfile
4036
ruby-version: 3.0
37+
- gemfile: gemfiles/rails_7.1.x.gemfile
38+
ruby-version: 3.1
39+
- gemfile: gemfiles/rails_7.1.x.gemfile
40+
ruby-version: 3.2
41+
- gemfile: gemfiles/rails_7.2.x.gemfile
42+
ruby-version: 3.3
4143
steps:
42-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v4
4345
- name: Set up Ruby ${{ matrix.ruby-version }}
4446
uses: ruby/setup-ruby@v1
4547
with:

arel-helpers.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
1616

1717
s.add_development_dependency 'appraisal'
1818
s.add_development_dependency 'combustion', '~> 1.3'
19-
s.add_development_dependency 'database_cleaner', '~> 1.8'
19+
s.add_development_dependency 'database_cleaner', '~> 2.0'
2020
s.add_development_dependency 'rake'
2121
s.add_development_dependency 'rspec', '~> 3'
2222
s.add_development_dependency 'sqlite3', '~> 1.4.0'

gemfiles/rails_4.0.x.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ source "https://rubygems.org"
44

55
gem "activerecord", "~> 4.0.0"
66
gem "sqlite3", "~> 1.3.0"
7+
gem "database_cleaner", "~> 1.8.0"
78

89
gemspec path: "../"

gemfiles/rails_4.1.x.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ source "https://rubygems.org"
44

55
gem "activerecord", "~> 4.1.0"
66
gem "sqlite3", "~> 1.3.0"
7+
gem "database_cleaner", "~> 1.8.0"
78

89
gemspec path: "../"

gemfiles/rails_4.2.x.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ source "https://rubygems.org"
44

55
gem "activerecord", "~> 4.2.0"
66
gem "sqlite3", "~> 1.3.0"
7+
gem "database_cleaner", "~> 1.8.0"
78

89
gemspec path: "../"

gemfiles/rails_5.0.x.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ source "https://rubygems.org"
44

55
gem "activerecord", "~> 5.0.0"
66
gem "sqlite3", "~> 1.3.0"
7+
gem "database_cleaner", "~> 1.8.0"
78

89
gemspec path: "../"

gemfiles/rails_3.1.x.gemfile renamed to gemfiles/rails_7.1.x.gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
source "https://rubygems.org"
44

5-
gem "activerecord", "~> 3.1.0"
6-
gem "sqlite3", "~> 1.3.0"
5+
gem "activerecord", "~> 7.1.0"
76

87
gemspec path: "../"

gemfiles/rails_3.2.x.gemfile renamed to gemfiles/rails_7.2.x.gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
source "https://rubygems.org"
44

5-
gem "activerecord", "~> 3.2.0"
6-
gem "sqlite3", "~> 1.3.0"
5+
gem "activerecord", "~> 7.2.0"
76

87
gemspec path: "../"

lib/arel-helpers/join_association.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class << self
1818
# This method encapsulates that functionality and yields an intermediate object for chaining.
1919
# It also allows you to use an outer join instead of the default inner via the join_type arg.
2020
def join_association(table, association, join_type = Arel::Nodes::InnerJoin, options = {}, &block)
21-
if version >= '6.1.0'
21+
if version >= "7.2.0"
22+
join_association_7_2_0(table, association, join_type, options, &block)
23+
elsif version >= '6.1.0'
2224
join_association_6_1_0(table, association, join_type, options, &block)
2325
elsif version >= '6.0.0'
2426
join_association_6_0_0(table, association, join_type, options, &block)
@@ -262,6 +264,33 @@ def join_association_6_1_0(table, association, join_type, options = {})
262264
end
263265
end
264266

267+
def join_association_7_2_0(table, association, join_type, options = {})
268+
aliases = options.fetch(:aliases, []).index_by(&:table_name)
269+
associations = association.is_a?(Array) ? association : [association]
270+
271+
alias_tracker = ActiveRecord::Associations::AliasTracker.create(
272+
table.connection_pool, table.name, {}
273+
)
274+
275+
join_dependency = ActiveRecord::Associations::JoinDependency.new(
276+
table, table.arel_table, associations, join_type
277+
)
278+
279+
constraints = join_dependency.join_constraints([], alias_tracker, [])
280+
281+
constraints.map do |join|
282+
apply_aliases(join, aliases)
283+
284+
right = if block_given?
285+
yield join.left.name.to_sym, join.right
286+
else
287+
join.right
288+
end
289+
290+
join_type.new(join.left, right)
291+
end
292+
end
293+
265294
def apply_aliases(node, aliases)
266295
case node
267296
when Arel::Nodes::Join

0 commit comments

Comments
 (0)