baby_squeel 1.4.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/ISSUE_TEMPLATE.md +1 -1
- data/baby_squeel.gemspec +1 -1
- data/lib/baby_squeel/active_record/query_methods.rb +4 -12
- data/lib/baby_squeel/active_record/version_helper.rb +0 -9
- data/lib/baby_squeel/join_dependency.rb +4 -31
- data/lib/baby_squeel/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e317da76921bc04f342b3cd1f219fa6585f642c4b96e936a18a442a1eb51c18b
|
4
|
+
data.tar.gz: 6a25d3d64d518f5b43124b4dd9083636f10ac0fad1e0ba4e9634f0dded17cb23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1bcaadbb4fc5894a5cd1e4c797ac3d6cfbbaee0cad994caf360fc2ac347f9a30019c297bcd254cae7642574b56bd22d927ea492bad76be02905379847af5330
|
7
|
+
data.tar.gz: 012e06a95f564e7502a4aa73a5629969f82e76a4abf475fa7364f25891f3345710334848313d6c3fc4c3842da29c5fc3220d95d58a1829258445886be8ac143e
|
data/CHANGELOG.md
CHANGED
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', '~>
|
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', '>=
|
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'
|
@@ -64,10 +64,12 @@ module BabySqueel
|
|
64
64
|
|
65
65
|
# https://github.com/rails/rails/commit/c0c53ee9d28134757cf1418521cb97c4a135f140
|
66
66
|
def select_association_list(*args)
|
67
|
-
args[0].
|
67
|
+
if args[0].any? { |join| join.is_a?(BabySqueel::Join) }
|
68
|
+
args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
|
69
|
+
end
|
68
70
|
super *args
|
69
71
|
end
|
70
|
-
|
72
|
+
else
|
71
73
|
private
|
72
74
|
|
73
75
|
# Active Record will call `each` on the `joins`. The
|
@@ -77,16 +79,6 @@ module BabySqueel
|
|
77
79
|
args[1] = BabySqueel::JoinDependency::Injector6_0.new(args.second)
|
78
80
|
super(*args)
|
79
81
|
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
|
-
end
|
90
82
|
end
|
91
83
|
end
|
92
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:
|
@@ -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
|
-
|
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
|
-
|
151
|
-
|
152
|
-
|
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
|
data/lib/baby_squeel/version.rb
CHANGED
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:
|
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-
|
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: '
|
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: '
|
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.3.
|
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.
|