arel-helpers 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 667479f8a68b5bb0af49054dea8aad1071976d752ca00f1e6cd4560005b71ba7
4
- data.tar.gz: 0d7d43d81c584cf98a7a2becb0cc61e9f36af9cc24296146d0e4857855a9ef4b
3
+ metadata.gz: 1efc47376ccbcdad46e62a6065618121a0335003227ab3bfb9edc504094e6f44
4
+ data.tar.gz: 5b18eb15dc5ae7123b74a89360771568cd5b2e1ac5ce592e872c29dc3ed9c5a6
5
5
  SHA512:
6
- metadata.gz: 07545d1df75177211b9e40302b3273df2eac33d29dc3ad42fa8c737b06711f2cdbf6455e1e2b90cb523a7248bfece31e8b16296501c103a8f65c513cf21dde02
7
- data.tar.gz: 978312ef3268e698c8b155fad5bdbdf084a5175a1a753b8367386d8f116af2fbacb58601288987a3e8cc3a6755eb1efee9412eb459aec72a1990ecb6112e8c1a
6
+ metadata.gz: dee579a6df63b01c485c40e46574d24852f4cd95c546168dcaa58a527d6fd35cfe8de3d3dc33f428b7087abf7ec5da9c510fec2575ab3bb52f685c54c7e17541
7
+ data.tar.gz: ab160a5fbc698c823804a3caf55ca3f921512aa3b7892bef9871e20e579419fc879d84dfba41c03cc60a867e6f2c7c957aa1d0d21b3fc343681781bf46f794ae
data/README.md CHANGED
@@ -215,7 +215,7 @@ This can become repetitive, and as an alternative you can choose to prepend `not
215
215
 
216
216
  ## Requirements
217
217
 
218
- Requires ActiveRecord >= 3.1.0, < 7. Depends on SQLite for testing purposes.
218
+ Requires ActiveRecord >= 3.1.0, < 8. Depends on SQLite for testing purposes.
219
219
 
220
220
  ## Running Tests
221
221
 
data/arel-helpers.gemspec CHANGED
@@ -16,10 +16,10 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_development_dependency 'appraisal'
18
18
  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'
20
20
  s.add_development_dependency 'rake'
21
21
  s.add_development_dependency 'rspec', '~> 3'
22
- s.add_development_dependency 'sqlite3', '~> 1.4.0'
22
+ s.add_development_dependency 'sqlite3', '~> 1.4'
23
23
 
24
24
  s.require_path = 'lib'
25
25
  s.files = Dir['{lib,spec}/**/*', 'Gemfile', 'History.txt', 'README.md', 'Rakefile', 'arel-helpers.gemspec']
@@ -18,7 +18,9 @@ module ArelHelpers
18
18
  # This method encapsulates that functionality and yields an intermediate object for chaining.
19
19
  # It also allows you to use an outer join instead of the default inner via the join_type arg.
20
20
  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'
22
24
  join_association_6_1_0(table, association, join_type, options, &block)
23
25
  elsif version >= '6.0.0'
24
26
  join_association_6_0_0(table, association, join_type, options, &block)
@@ -262,6 +264,33 @@ module ArelHelpers
262
264
  end
263
265
  end
264
266
 
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
+
265
294
  def apply_aliases(node, aliases)
266
295
  case node
267
296
  when Arel::Nodes::Join
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module ArelHelpers
4
- VERSION = '2.14.0'
4
+ VERSION = '2.15.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-16 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '1.8'
67
+ version: '2.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '1.8'
74
+ version: '2.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -106,14 +106,14 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 1.4.0
109
+ version: '1.4'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 1.4.0
116
+ version: '1.4'
117
117
  description: Useful tools to help construct database queries with ActiveRecord and
118
118
  Arel.
119
119
  email:
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.2.22
162
+ rubygems_version: 3.5.3
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Useful tools to help construct database queries with ActiveRecord and Arel.