arel-helpers 2.9.1 → 2.10.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: 5daa252f2c9a256e38b204ab59498c59cb5848ff5250db46a9f35df110adac06
4
- data.tar.gz: cc955446d243cbfe1285188b435911876b884bdd989920596ec547df410f48eb
3
+ metadata.gz: 209526ee9962414d0eb5bab7820f6c97cfc51edf362d4ccdaf6b7309e7196fbe
4
+ data.tar.gz: e3923216fd30b2ab762c581ef0056145a1b09758433159123bee1df3443bc924
5
5
  SHA512:
6
- metadata.gz: 5198b3ec78bb0f2379bd59de580623d238ffc4b608796b45e1afc5effb2a749c5e7da8934947e7fa1675230ca69ea1ca14b016907c24b1e095a190419158258c
7
- data.tar.gz: 20ed995c0792e698f40fddb31ca8568828450eda52cb9b83b98d3a94b7379c6a0488aee19e82a4d12ea5960a470c0bb3806eb3813da27d16329057c6361e8852
6
+ metadata.gz: 48814845832553b87d496b70982c46a905b0a2aecba5426d3f9e36f3fc2436cee0e71e68ab733fbc0b37cf90981515de695f309d5a4ea35d49becc83d4d1703f
7
+ data.tar.gz: 638fa0c5ed41050e17bdd642fab0b4dfc94e0d3bb8084a1ca9c6cc89a9d340f11aadc0d0ba98d78628ecf4bbacd465385074cc1f0f82167f1b50298361672472
data/Gemfile CHANGED
@@ -1,16 +1,2 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development, :test do
6
- gem 'pry-byebug'
7
-
8
- # lock to 10.0 until rspec is upgraded
9
- gem 'rake', '~> 10.0'
10
- end
11
-
12
- group :test do
13
- gem 'rspec', '~> 2.11.0'
14
- gem 'rr', '~> 1.0.4'
15
- gem 'sqlite3'
16
- end
1
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile-rails-6.0.x', __FILE__)
2
+ Bundler.load
@@ -12,11 +12,11 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.platform = Gem::Platform::RUBY
14
14
 
15
- if ENV["AR"]
16
- s.add_dependency 'activerecord', ENV["AR"]
17
- else
18
- s.add_dependency 'activerecord', '>= 3.1.0', '< 7'
19
- end
15
+ s.add_dependency 'activerecord', '>= 3.1.0', '< 7'
16
+
17
+ s.add_development_dependency 'rake', '~> 10.0'
18
+ s.add_development_dependency 'rspec', '~> 2.11'
19
+ s.add_development_dependency 'rr', '~> 1.0'
20
20
 
21
21
  s.require_path = 'lib'
22
22
  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 >= '5.2.1'
21
+ if version >= '6.0.0'
22
+ join_association_6_0_0(table, association, join_type, options, &block)
23
+ elsif version >= '5.2.1'
22
24
  join_association_5_2_1(table, association, join_type, options, &block)
23
25
  elsif version >= '5.2.0'
24
26
  join_association_5_2(table, association, join_type, options, &block)
@@ -217,6 +219,35 @@ module ArelHelpers
217
219
  end
218
220
  end
219
221
 
222
+ def join_association_6_0_0(table, association, join_type, options = {})
223
+ aliases = options.fetch(:aliases, [])
224
+ associations = association.is_a?(Array) ? association : [association]
225
+
226
+ alias_tracker = ActiveRecord::Associations::AliasTracker.create(
227
+ table.connection, table.name, {}
228
+ )
229
+
230
+ join_dependency = ActiveRecord::Associations::JoinDependency.new(
231
+ table, table.arel_table, associations, join_type
232
+ )
233
+
234
+ constraints = join_dependency.join_constraints([], alias_tracker)
235
+
236
+ constraints.map do |join|
237
+ right = if block_given?
238
+ yield join.left.name.to_sym, join.right
239
+ else
240
+ join.right
241
+ end
242
+
243
+ if found_alias = find_alias(join.left.name, aliases)
244
+ join.left.table_alias = found_alias.name
245
+ end
246
+
247
+ join_type.new(join.left, right)
248
+ end
249
+ end
250
+
220
251
  private
221
252
 
222
253
  def to_sql(node, table, binds)
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module ArelHelpers
4
- VERSION = '2.9.1'
4
+ VERSION = '2.10.0'
5
5
  end
@@ -5,7 +5,6 @@ $:.push(File.dirname(__FILE__))
5
5
  require 'rspec'
6
6
  require 'arel-helpers'
7
7
  require 'fileutils'
8
- require 'pry-byebug'
9
8
 
10
9
  require 'env'
11
10
 
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.9.1
4
+ version: 2.10.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: 2019-06-11 00:00:00.000000000 Z
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,6 +30,48 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '10.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.11'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.11'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rr
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
33
75
  description: Useful tools to help construct database queries with ActiveRecord and
34
76
  Arel.
35
77
  email:
@@ -76,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
118
  - !ruby/object:Gem::Version
77
119
  version: '0'
78
120
  requirements: []
79
- rubyforge_project:
80
- rubygems_version: 2.7.6
121
+ rubygems_version: 3.0.4
81
122
  signing_key:
82
123
  specification_version: 4
83
124
  summary: Useful tools to help construct database queries with ActiveRecord and Arel.