baby_squeel 1.4.4 → 3.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: 54dbc98299ab8f9909d8c312e9663cc615543ea6421b81f2aab6efdd2bd9fe59
4
- data.tar.gz: 97cc39dced57e0bd6bf16c854859f47902a2d6550e71c4120643fb01d0de9529
3
+ metadata.gz: 763bb8a79bfc992f8fd3dfab9f6fd10075ad6ebdc10a1c1c6136f7b41be96805
4
+ data.tar.gz: d895cddcf544c0c04b02908b8bb8423fdb378d132df6454766e4770973b82abc
5
5
  SHA512:
6
- metadata.gz: 8f5e68cf4ac0e85d2dc8fce1741f2d64c2bd5b5ecc08c335d71ad3fae335fb3b580f5c3aa2c5f98053ec445d9a7fbc1d3ddec6c7218c99bcb9869a6767fa68c8
7
- data.tar.gz: ca66ea54876dfb670177ccea3be1808c90b4d1affea3b7bc1cb5c515e6e8208a8b55fb9fcd06202c6411ea102a358ceb0aa7d0468f82ee7c857045fbc0c5e946
6
+ metadata.gz: 3034a5daf5a2473fdeab546af7501fba5840e57977b802448fa3d976933ba17745e79511291156105f5da1ee748a5fe597084cdeade003c9df49850c6d387383
7
+ data.tar.gz: b506444e62ef4c58aead98f1c6d3a8a201b6dc47f9d3245129c492520ff6541e248f7b7463b4407e9125683199cc4396f696973e78ea19fd5ba4bf0a31459e4c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [3.0.0] - 2023-11-20
4
+
5
+ - Added support for ActiveRecord 7.1 (#125)
6
+ - Added support for Ruby 3.2 (#128)
7
+ - Updated ransack to 4.1. (#126)
8
+ - Droped support for Ruby 2.6 and 2.7. (#126)
9
+ - Droped support for ActiveRecord 6.0. (#126)
10
+
11
+ ## [2.0.0] - 2022-08-28
12
+
13
+ - AR 6.1: fix - FrozenError: can't modify frozen object: []
14
+ - Drop support for ActiveRecord older than 6.0.
15
+
3
16
  ## [1.4.4] - 2022-02-07
4
17
 
5
18
  ### Fixed
@@ -231,7 +244,9 @@
231
244
 
232
245
  - Initial support for selects, orders, wheres, and joins.
233
246
 
234
- [unreleased]: https://github.com/rzane/baby_squeel/compare/v1.4.4...HEAD
247
+ [unreleased]: https://github.com/rzane/baby_squeel/compare/v3.0.0...HEAD
248
+ [3.0.0]: https://github.com/rzane/baby_squeel/compare/v2.0.0...v3.0.0
249
+ [2.0.0]: https://github.com/rzane/baby_squeel/compare/v1.4.4...v2.0.0
235
250
  [1.4.4]: https://github.com/rzane/baby_squeel/compare/v1.4.3...v1.4.4
236
251
  [1.4.3]: https://github.com/rzane/baby_squeel/compare/v1.4.2...v1.4.3
237
252
  [1.4.2]: https://github.com/rzane/baby_squeel/compare/v1.4.1...v1.4.2
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', '~> 7.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
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Ray Zane']
10
10
  spec.email = ['ray@promptworks.com']
11
11
 
12
- spec.summary = 'An expressive query DSL for Active Record 4 and 5.'
12
+ spec.summary = 'An expressive query DSL for Active Record 6+'
13
13
  spec.description = spec.summary
14
14
  spec.homepage = 'https://github.com/rzane/baby_squeel'
15
15
  spec.license = 'MIT'
@@ -19,8 +19,8 @@ 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'
23
- spec.add_dependency 'ransack', '~> 2.3'
22
+ spec.add_dependency 'activerecord', '>= 6.1.5', '< 7.2'
23
+ spec.add_dependency 'ransack', '~> 4.1'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 2'
26
26
  spec.add_development_dependency 'rake', '~> 13.0'
@@ -51,42 +51,22 @@ module BabySqueel
51
51
  having DSL.evaluate(self, &block)
52
52
  end
53
53
 
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
54
+ def construct_join_dependency(associations, join_type)
55
+ result = super(associations, join_type)
56
+ if associations.any? { |assoc| assoc.is_a?(BabySqueel::Join) }
57
+ result.extend(BabySqueel::JoinDependency::Injector6_1)
61
58
  end
59
+ result
60
+ end
62
61
 
63
- private
62
+ private
64
63
 
65
- # https://github.com/rails/rails/commit/c0c53ee9d28134757cf1418521cb97c4a135f140
66
- def select_association_list(*args)
64
+ # https://github.com/rails/rails/commit/c0c53ee9d28134757cf1418521cb97c4a135f140
65
+ def select_association_list(*args)
66
+ if args[0].any? { |join| join.is_a?(BabySqueel::Join) }
67
67
  args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
68
- super *args
69
- end
70
- elsif BabySqueel::ActiveRecord::VersionHelper.at_least_6_0?
71
- private
72
-
73
- # Active Record will call `each` on the `joins`. The
74
- # Injector has a custom `each` method that handles
75
- # BabySqueel::Join nodes.
76
- def build_joins(*args)
77
- args[1] = BabySqueel::JoinDependency::Injector6_0.new(args.second)
78
- super(*args)
79
- end
80
- else
81
- private
82
-
83
- # Active Record will call `group_by` on the `joins`. The
84
- # Injector has a custom `group_by` method that handles
85
- # BabySqueel::Join nodes.
86
- def build_joins(*args)
87
- args[1] = BabySqueel::JoinDependency::Injector5_2.new(args.second)
88
- super(*args)
89
68
  end
69
+ super *args
90
70
  end
91
71
  end
92
72
  end
@@ -3,19 +3,13 @@ require 'baby_squeel/dsl'
3
3
  module BabySqueel
4
4
  module ActiveRecord
5
5
  class VersionHelper
6
- def self.at_least_6_1?
7
- ::ActiveRecord::VERSION::MAJOR > 6 ||
8
- ::ActiveRecord::VERSION::MAJOR == 6 && ::ActiveRecord::VERSION::MINOR >= 1
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
6
+ # Example
7
+ # BabySqueel::ActiveRecord::VersionHelper.at_least_7_1?
8
+ #
9
+ # def self.at_least_7_1?
10
+ # ::ActiveRecord::VERSION::MAJOR > 7 ||
11
+ # ::ActiveRecord::VERSION::MAJOR == 7 && ::ActiveRecord::VERSION::MINOR >= 1
12
+ # end
19
13
  end
20
14
  end
21
15
  end
@@ -100,13 +100,7 @@ module BabySqueel
100
100
  def build_where_clause(other)
101
101
  if valid_where_clause?(other)
102
102
  relation = @parent._scope.all
103
-
104
- if BabySqueel::ActiveRecord::VersionHelper.at_least_6_1?
105
- relation.send(:build_where_clause, { _reflection.name => other }, [])
106
- else
107
- factory = relation.send(:where_clause_factory)
108
- factory.build({ _reflection.name => other }, [])
109
- end
103
+ relation.send(:build_where_clause, { _reflection.name => other }, [])
110
104
  else
111
105
  raise AssociationComparisonError.new(_reflection.name, other)
112
106
  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:
@@ -66,20 +46,13 @@ module BabySqueel
66
46
  # a list (in order of chaining) of associations and finding
67
47
  # the respective JoinAssociation at each level.
68
48
  def find_alias(associations)
69
- if BabySqueel::ActiveRecord::VersionHelper.at_least_6_1?
70
- # construct_tables! got removed by rails
71
- # https://github.com/rails/rails/commit/590b045ee2c0906ff162e6658a184afb201865d7
72
- #
73
- # construct_tables_for_association! is a method from the polyamorous (ransack) gem
74
- join_root = join_dependency.send(:join_root)
75
- join_root.each_children do |parent, child|
76
- join_dependency.construct_tables_for_association!(parent, child)
77
- end
78
- elsif BabySqueel::ActiveRecord::VersionHelper.at_least_5_2_3?
79
- # If we tell join_dependency to construct its tables, Active Record
80
- # handles building the correct aliases and attaching them to its
81
- # JoinDepenencies.
82
- join_dependency.send(:construct_tables!, join_dependency.send(:join_root))
49
+ # construct_tables! got removed by rails
50
+ # https://github.com/rails/rails/commit/590b045ee2c0906ff162e6658a184afb201865d7
51
+ #
52
+ # construct_tables_for_association! is a method from the polyamorous (ransack) gem
53
+ join_root = join_dependency.send(:join_root)
54
+ join_root.each_children do |parent, child|
55
+ join_dependency.construct_tables_for_association!(parent, child)
83
56
  end
84
57
 
85
58
  join_association = find_join_association(associations)
@@ -115,7 +88,7 @@ module BabySqueel
115
88
  joins += relation.joins_values
116
89
  joins += relation.left_outer_joins_values
117
90
 
118
- buckets = joins.group_by do |join|
91
+ _buckets = joins.group_by do |join|
119
92
  case join
120
93
  when String
121
94
  :string_join
@@ -147,16 +120,9 @@ module BabySqueel
147
120
  join_list = join_nodes + joins
148
121
 
149
122
  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
123
+ join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::InnerJoin)
124
+ join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
125
+
160
126
  join_nodes.each do |join|
161
127
  join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
162
128
  end
@@ -41,7 +41,7 @@ module BabySqueel
41
41
  # Conveniently, this approach automatically adds a 1=0.
42
42
  # I have literally no idea why, but I'll take it.
43
43
  def sanitize_relation(rel)
44
- if rel.kind_of? ::ActiveRecord::NullRelation
44
+ if ::ActiveRecord::VERSION::MAJOR < 7 && rel.kind_of?(::ActiveRecord::NullRelation)
45
45
  other = rel.spawn
46
46
  other.extending_values -= [::ActiveRecord::NullRelation]
47
47
  sanitize_relation rel.unscoped.merge(other)
@@ -1,3 +1,3 @@
1
1
  module BabySqueel
2
- VERSION = '1.4.4'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
data/lib/baby_squeel.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  require 'active_record'
2
2
  require 'active_record/relation'
3
- begin
4
- require 'polyamorous'
5
- rescue LoadError
6
- # Trying loading from 'ransack' as of commit c9cc20de9 (post v2.3.2)
7
- require 'polyamorous/polyamorous'
8
- end
3
+ # Loading polyamorous from 'ransack' as of commit c9cc20de9 (post v2.3.2)
4
+ require 'polyamorous/polyamorous'
9
5
  require 'baby_squeel/version'
10
6
  require 'baby_squeel/errors'
11
7
  require 'baby_squeel/active_record/base'
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.4
4
+ version: 3.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-02-08 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,34 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: 6.1.5
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.1'
22
+ version: '7.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.2'
29
+ version: 6.1.5
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.1'
32
+ version: '7.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: ransack
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.3'
39
+ version: '4.1'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.3'
46
+ version: '4.1'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -100,7 +100,7 @@ dependencies:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
- description: An expressive query DSL for Active Record 4 and 5.
103
+ description: An expressive query DSL for Active Record 6+
104
104
  email:
105
105
  - ray@promptworks.com
106
106
  executables: []
@@ -156,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.3.3
159
+ rubygems_version: 3.4.13
160
160
  signing_key:
161
161
  specification_version: 4
162
- summary: An expressive query DSL for Active Record 4 and 5.
162
+ summary: An expressive query DSL for Active Record 6+
163
163
  test_files: []