baby_squeel 1.4.2 → 2.0.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: 154cc7b5379993dfa67f76c182bfe810f5c9b941930ec69e386270e5751201da
4
- data.tar.gz: 873324d4d500c03621c6a3fb20321a948f2b9ae9dadf098aff028b154dc57f36
3
+ metadata.gz: e317da76921bc04f342b3cd1f219fa6585f642c4b96e936a18a442a1eb51c18b
4
+ data.tar.gz: 6a25d3d64d518f5b43124b4dd9083636f10ac0fad1e0ba4e9634f0dded17cb23
5
5
  SHA512:
6
- metadata.gz: b29e8eb5d1225e3e8f00908af60da6b5deeebeb49467a52aa875fcad70972002d312dac0151be4d4ca7562012cc7c21593c630f1b44b2f20733cb43bdc997854
7
- data.tar.gz: 3b3b9957bc49729ffdcf5bda14ef4446816cf8cbd12facf67a30ec8912bbb260e0a0543334a3e840a0d691ee8d990754dbe23e687129321b88a46360b2d60e76
6
+ metadata.gz: f1bcaadbb4fc5894a5cd1e4c797ac3d6cfbbaee0cad994caf360fc2ac347f9a30019c297bcd254cae7642574b56bd22d927ea492bad76be02905379847af5330
7
+ data.tar.gz: 012e06a95f564e7502a4aa73a5629969f82e76a4abf475fa7364f25891f3345710334848313d6c3fc4c3842da29c5fc3220d95d58a1829258445886be8ac143e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
+ - AR 6.1: fix - FrozenError: can't modify frozen object: []
4
+ - Drop support for ActiveRecord older than 6.0.
5
+
6
+ ## [1.4.4] - 2022-02-07
7
+
8
+ ### Fixed
9
+
10
+ - Nested merge-joins query causes NoMethodError with ActiveRecord 6.1.4.4 (#119)
11
+
12
+ ## [1.4.3] - 2022-02-04
13
+
14
+ ### Fixed
15
+
16
+ - ActiveRecord::Relation#left_joins performs INNER JOIN on Active Record 6.1 (#118)
17
+
3
18
  ## [1.4.2] - 2022-01-24
4
19
 
5
20
  ### Fixed
@@ -219,7 +234,9 @@
219
234
 
220
235
  - Initial support for selects, orders, wheres, and joins.
221
236
 
222
- [unreleased]: https://github.com/rzane/baby_squeel/compare/v1.4.2...HEAD
237
+ [unreleased]: https://github.com/rzane/baby_squeel/compare/v1.4.4...HEAD
238
+ [1.4.4]: https://github.com/rzane/baby_squeel/compare/v1.4.3...v1.4.4
239
+ [1.4.3]: https://github.com/rzane/baby_squeel/compare/v1.4.2...v1.4.3
223
240
  [1.4.2]: https://github.com/rzane/baby_squeel/compare/v1.4.1...v1.4.2
224
241
  [1.4.1]: https://github.com/rzane/baby_squeel/compare/v1.4.0...v1.4.1
225
242
  [1.4.0]: https://github.com/rzane/baby_squeel/compare/v1.4.0.beta1...v1.4.0
data/ISSUE_TEMPLATE.md CHANGED
@@ -11,7 +11,7 @@ require 'minitest/autorun'
11
11
 
12
12
  gemfile true do
13
13
  source 'https://rubygems.org'
14
- gem 'activerecord', '~> 5.2.0' # which Active Record version?
14
+ gem 'activerecord', '~> 6.0.0' # which Active Record version?
15
15
  gem 'sqlite3'
16
16
  gem 'baby_squeel', github: 'rzane/baby_squeel'
17
17
  end
data/baby_squeel.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}')
21
21
 
22
- spec.add_dependency 'activerecord', '>= 5.2', '< 7.1'
22
+ spec.add_dependency 'activerecord', '>= 6.0', '< 7.1'
23
23
  spec.add_dependency 'ransack', '~> 2.3'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 2'
@@ -51,19 +51,27 @@ module BabySqueel
51
51
  having DSL.evaluate(self, &block)
52
52
  end
53
53
 
54
- private
55
-
56
54
  if BabySqueel::ActiveRecord::VersionHelper.at_least_6_1?
55
+ def construct_join_dependency(associations, join_type)
56
+ result = super(associations, join_type)
57
+ if associations.any? { |assoc| assoc.is_a?(BabySqueel::Join) }
58
+ result.extend(BabySqueel::JoinDependency::Injector6_1)
59
+ end
60
+ result
61
+ end
62
+
63
+ private
64
+
57
65
  # https://github.com/rails/rails/commit/c0c53ee9d28134757cf1418521cb97c4a135f140
58
66
  def select_association_list(*args)
59
- args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
67
+ if args[0].any? { |join| join.is_a?(BabySqueel::Join) }
68
+ args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
69
+ end
60
70
  super *args
61
71
  end
72
+ else
73
+ private
62
74
 
63
- def construct_join_dependency(associations, join_type)
64
- super(associations, join_type).extend(BabySqueel::JoinDependency::Injector6_1)
65
- end
66
- elsif BabySqueel::ActiveRecord::VersionHelper.at_least_6_0?
67
75
  # Active Record will call `each` on the `joins`. The
68
76
  # Injector has a custom `each` method that handles
69
77
  # BabySqueel::Join nodes.
@@ -71,14 +79,6 @@ module BabySqueel
71
79
  args[1] = BabySqueel::JoinDependency::Injector6_0.new(args.second)
72
80
  super(*args)
73
81
  end
74
- else
75
- # Active Record will call `group_by` on the `joins`. The
76
- # Injector has a custom `group_by` method that handles
77
- # BabySqueel::Join nodes.
78
- def build_joins(*args)
79
- args[1] = BabySqueel::JoinDependency::Injector5_2.new(args.second)
80
- super(*args)
81
- end
82
82
  end
83
83
  end
84
84
  end
@@ -7,15 +7,6 @@ module BabySqueel
7
7
  ::ActiveRecord::VERSION::MAJOR > 6 ||
8
8
  ::ActiveRecord::VERSION::MAJOR == 6 && ::ActiveRecord::VERSION::MINOR >= 1
9
9
  end
10
-
11
- def self.at_least_6_0?
12
- ::ActiveRecord::VERSION::MAJOR >= 6
13
- end
14
-
15
- def self.at_least_5_2_3?
16
- at_least_6_0? ||
17
- ::ActiveRecord::VERSION::MAJOR >= 5 && ::ActiveRecord::VERSION::MINOR >= 2 && ::ActiveRecord::VERSION::TINY >= 3
18
- end
19
10
  end
20
11
  end
21
12
  end
@@ -2,26 +2,6 @@ require 'baby_squeel/active_record/version_helper'
2
2
 
3
3
  module BabySqueel
4
4
  module JoinDependency
5
- # This class allows BabySqueel to slip custom
6
- # joins_values into Active Record's JoinDependency
7
- class Injector5_2 < Array # :nodoc:
8
- # Active Record will call group_by on this object
9
- # in ActiveRecord::QueryMethods#build_joins. This
10
- # allows BabySqueel::Joins to be treated
11
- # like typical join hashes until Polyamorous can
12
- # deal with them.
13
- def group_by
14
- super do |join|
15
- case join
16
- when BabySqueel::Join
17
- :association_join
18
- else
19
- yield join
20
- end
21
- end
22
- end
23
- end
24
-
25
5
  # This class allows BabySqueel to slip custom
26
6
  # joins_values into Active Record's JoinDependency
27
7
  class Injector6_0 < Array # :nodoc:
@@ -50,7 +30,7 @@ module BabySqueel
50
30
  # Maybe this could be fixed in joining but I do not know how.
51
31
  module Injector6_1 # :nodoc:
52
32
  def make_constraints(parent, child, join_type) # :nodoc:
53
- join_type = child.join_type if child.join_type
33
+ join_type = child.join_type if child.join_type == Arel::Nodes::OuterJoin
54
34
  super(parent, child, join_type)
55
35
  end
56
36
  end
@@ -75,7 +55,7 @@ module BabySqueel
75
55
  join_root.each_children do |parent, child|
76
56
  join_dependency.construct_tables_for_association!(parent, child)
77
57
  end
78
- elsif BabySqueel::ActiveRecord::VersionHelper.at_least_5_2_3?
58
+ else
79
59
  # If we tell join_dependency to construct its tables, Active Record
80
60
  # handles building the correct aliases and attaching them to its
81
61
  # JoinDepenencies.
@@ -147,16 +127,9 @@ module BabySqueel
147
127
  join_list = join_nodes + joins
148
128
 
149
129
  alias_tracker = Associations::AliasTracker.create(relation.klass.connection, relation.table.name, join_list)
150
- if BabySqueel::ActiveRecord::VersionHelper.at_least_6_0?
151
- join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::InnerJoin)
152
- join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
153
- elsif BabySqueel::ActiveRecord::VersionHelper.at_least_5_2_3?
154
- join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins)
155
- join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
156
- else
157
- # Rails 5.2.0 - 5.2.2
158
- join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins, alias_tracker)
159
- end
130
+ join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::InnerJoin)
131
+ join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
132
+
160
133
  join_nodes.each do |join|
161
134
  join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
162
135
  end
@@ -1,3 +1,3 @@
1
1
  module BabySqueel
2
- VERSION = '1.4.2'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baby_squeel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Zane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '7.1'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.2'
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7.1'
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.2.22
159
+ rubygems_version: 3.3.7
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: An expressive query DSL for Active Record 4 and 5.