baby_squeel 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/ISSUE_TEMPLATE.md +1 -1
- data/baby_squeel.gemspec +3 -3
- data/lib/baby_squeel/active_record/query_methods.rb +12 -24
- data/lib/baby_squeel/active_record/version_helper.rb +7 -4
- data/lib/baby_squeel/association.rb +1 -7
- data/lib/baby_squeel/join_dependency.rb +8 -15
- data/lib/baby_squeel/nodes/attribute.rb +1 -1
- data/lib/baby_squeel/version.rb +1 -1
- data/lib/baby_squeel.rb +2 -6
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 763bb8a79bfc992f8fd3dfab9f6fd10075ad6ebdc10a1c1c6136f7b41be96805
|
4
|
+
data.tar.gz: d895cddcf544c0c04b02908b8bb8423fdb378d132df6454766e4770973b82abc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3034a5daf5a2473fdeab546af7501fba5840e57977b802448fa3d976933ba17745e79511291156105f5da1ee748a5fe597084cdeade003c9df49850c6d387383
|
7
|
+
data.tar.gz: b506444e62ef4c58aead98f1c6d3a8a201b6dc47f9d3245129c492520ff6541e248f7b7463b4407e9125683199cc4396f696973e78ea19fd5ba4bf0a31459e4c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
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
|
+
|
3
13
|
- AR 6.1: fix - FrozenError: can't modify frozen object: []
|
4
14
|
- Drop support for ActiveRecord older than 6.0.
|
5
15
|
|
@@ -234,7 +244,9 @@
|
|
234
244
|
|
235
245
|
- Initial support for selects, orders, wheres, and joins.
|
236
246
|
|
237
|
-
[unreleased]: https://github.com/rzane/baby_squeel/compare/
|
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
|
238
250
|
[1.4.4]: https://github.com/rzane/baby_squeel/compare/v1.4.3...v1.4.4
|
239
251
|
[1.4.3]: https://github.com/rzane/baby_squeel/compare/v1.4.2...v1.4.3
|
240
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', '~>
|
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
|
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', '>= 6.
|
23
|
-
spec.add_dependency 'ransack', '~>
|
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,34 +51,22 @@ module BabySqueel
|
|
51
51
|
having DSL.evaluate(self, &block)
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
64
|
-
|
65
|
-
# https://github.com/rails/rails/commit/c0c53ee9d28134757cf1418521cb97c4a135f140
|
66
|
-
def select_association_list(*args)
|
67
|
-
if args[0].any? { |join| join.is_a?(BabySqueel::Join) }
|
68
|
-
args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
|
69
|
-
end
|
70
|
-
super *args
|
71
|
-
end
|
72
|
-
else
|
73
|
-
private
|
62
|
+
private
|
74
63
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
args[1] = BabySqueel::JoinDependency::Injector6_0.new(args.second)
|
80
|
-
super(*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
|
+
args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
|
81
68
|
end
|
69
|
+
super *args
|
82
70
|
end
|
83
71
|
end
|
84
72
|
end
|
@@ -3,10 +3,13 @@ require 'baby_squeel/dsl'
|
|
3
3
|
module BabySqueel
|
4
4
|
module ActiveRecord
|
5
5
|
class VersionHelper
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
10
13
|
end
|
11
14
|
end
|
12
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
|
@@ -46,20 +46,13 @@ module BabySqueel
|
|
46
46
|
# a list (in order of chaining) of associations and finding
|
47
47
|
# the respective JoinAssociation at each level.
|
48
48
|
def find_alias(associations)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
join_dependency.construct_tables_for_association!(parent, child)
|
57
|
-
end
|
58
|
-
else
|
59
|
-
# If we tell join_dependency to construct its tables, Active Record
|
60
|
-
# handles building the correct aliases and attaching them to its
|
61
|
-
# JoinDepenencies.
|
62
|
-
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)
|
63
56
|
end
|
64
57
|
|
65
58
|
join_association = find_join_association(associations)
|
@@ -95,7 +88,7 @@ module BabySqueel
|
|
95
88
|
joins += relation.joins_values
|
96
89
|
joins += relation.left_outer_joins_values
|
97
90
|
|
98
|
-
|
91
|
+
_buckets = joins.group_by do |join|
|
99
92
|
case join
|
100
93
|
when String
|
101
94
|
:string_join
|
@@ -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?
|
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)
|
data/lib/baby_squeel/version.rb
CHANGED
data/lib/baby_squeel.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'active_record/relation'
|
3
|
-
|
4
|
-
|
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:
|
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:
|
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:
|
19
|
+
version: 6.1.5
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
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:
|
29
|
+
version: 6.1.5
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
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: '
|
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: '
|
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
|
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.
|
159
|
+
rubygems_version: 3.4.13
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
|
-
summary: An expressive query DSL for Active Record
|
162
|
+
summary: An expressive query DSL for Active Record 6+
|
163
163
|
test_files: []
|