ransack 2.4.2 → 3.2.1
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/.github/workflows/cronjob.yml +6 -9
- data/.github/workflows/deploy.yml +35 -0
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/test-deploy.yml +29 -0
- data/.github/workflows/test.yml +16 -40
- data/.nojekyll +0 -0
- data/CHANGELOG.md +157 -11
- data/CONTRIBUTING.md +8 -7
- data/Gemfile +2 -2
- data/README.md +44 -972
- data/docs/.gitignore +19 -0
- data/docs/.nojekyll +0 -0
- data/docs/babel.config.js +3 -0
- data/docs/blog/2022-03-27-ransack-3.0.0.md +20 -0
- data/docs/docs/getting-started/_category_.json +4 -0
- data/docs/docs/getting-started/advanced-mode.md +46 -0
- data/docs/docs/getting-started/configuration.md +47 -0
- data/docs/docs/getting-started/search-matches.md +67 -0
- data/docs/docs/getting-started/simple-mode.md +284 -0
- data/docs/docs/getting-started/sorting.md +79 -0
- data/docs/docs/getting-started/using-predicates.md +282 -0
- data/docs/docs/going-further/_category_.json +4 -0
- data/docs/docs/going-further/acts-as-taggable-on.md +114 -0
- data/docs/docs/going-further/associations.md +70 -0
- data/docs/docs/going-further/custom-predicates.md +52 -0
- data/docs/docs/going-further/documentation.md +43 -0
- data/docs/docs/going-further/exporting-to-csv.md +49 -0
- data/docs/docs/going-further/external-guides.md +57 -0
- data/docs/docs/going-further/form-customisation.md +63 -0
- data/docs/docs/going-further/i18n.md +53 -0
- data/docs/docs/going-further/merging-searches.md +41 -0
- data/docs/docs/going-further/other-notes.md +428 -0
- data/docs/docs/going-further/polymorphic-search.md +40 -0
- data/docs/docs/going-further/ransackers.md +331 -0
- data/docs/docs/going-further/release_process.md +36 -0
- data/docs/docs/going-further/saving-queries.md +82 -0
- data/docs/docs/going-further/searching-postgres.md +57 -0
- data/docs/docs/going-further/wiki-contributors.md +82 -0
- data/docs/docs/intro.md +99 -0
- data/docs/docusaurus.config.js +120 -0
- data/docs/package.json +38 -0
- data/docs/sidebars.js +31 -0
- data/docs/src/components/HomepageFeatures/index.js +64 -0
- data/docs/src/components/HomepageFeatures/styles.module.css +11 -0
- data/docs/src/css/custom.css +39 -0
- data/docs/src/pages/index.module.css +23 -0
- data/docs/src/pages/markdown-page.md +7 -0
- data/docs/static/.nojekyll +0 -0
- data/docs/static/img/docusaurus.png +0 -0
- data/docs/static/img/favicon.ico +0 -0
- data/docs/static/img/logo.svg +1 -0
- data/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
- data/docs/static/img/tutorial/localeDropdown.png +0 -0
- data/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
- data/docs/static/img/undraw_docusaurus_react.svg +170 -0
- data/docs/static/img/undraw_docusaurus_tree.svg +40 -0
- data/docs/yarn.lock +8436 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -4
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -1
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -1
- data/lib/polyamorous/activerecord_7.1_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_7.1_ruby_2/join_dependency.rb +1 -0
- data/lib/polyamorous/activerecord_7.1_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous.rb +1 -0
- data/lib/ransack/adapters/active_record/base.rb +1 -3
- data/lib/ransack/adapters/active_record/context.rb +24 -51
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +2 -9
- data/lib/ransack/configuration.rb +16 -2
- data/lib/ransack/constants.rb +0 -3
- data/lib/ransack/helpers/form_helper.rb +11 -3
- data/lib/ransack/locale/sv.yml +70 -0
- data/lib/ransack/nodes/sort.rb +2 -2
- data/lib/ransack/nodes/value.rb +1 -1
- data/lib/ransack/search.rb +4 -3
- data/lib/ransack/translate.rb +1 -1
- data/lib/ransack/version.rb +1 -1
- data/ransack.gemspec +5 -5
- data/spec/helpers/polyamorous_helper.rb +2 -8
- data/spec/polyamorous/activerecord_compatibility_spec.rb +15 -0
- data/spec/polyamorous/join_association_spec.rb +1 -6
- data/spec/polyamorous/join_dependency_spec.rb +0 -16
- data/spec/ransack/adapters/active_record/base_spec.rb +28 -11
- data/spec/ransack/configuration_spec.rb +14 -0
- data/spec/ransack/helpers/form_helper_spec.rb +57 -2
- data/spec/ransack/nodes/condition_spec.rb +13 -0
- data/spec/ransack/nodes/value_spec.rb +115 -0
- data/spec/ransack/search_spec.rb +140 -27
- data/spec/support/schema.rb +49 -0
- metadata +82 -29
- data/docs/release_process.md +0 -20
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb +0 -24
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb +0 -79
- data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +0 -11
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -1
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -80
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -1
- /data/docs/{img → docs/going-further/img}/create_release.png +0 -0
- /data/{logo → docs/static/logo}/ransack-h.png +0 -0
- /data/{logo → docs/static/logo}/ransack-h.svg +0 -0
- /data/{logo → docs/static/logo}/ransack-v.png +0 -0
- /data/{logo → docs/static/logo}/ransack-v.svg +0 -0
- /data/{logo → docs/static/logo}/ransack.png +0 -0
- /data/{logo → docs/static/logo}/ransack.svg +0 -0
- /data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/join_association.rb +0 -0
- /data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/join_dependency.rb +0 -0
- /data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/reflection.rb +0 -0
metadata
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ransack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ernie Miller
|
|
8
8
|
- Ryan Bigg
|
|
9
9
|
- Jon Atack
|
|
10
10
|
- Sean Carroll
|
|
11
|
-
|
|
11
|
+
- David Rodríguez
|
|
12
|
+
autorequire:
|
|
12
13
|
bindir: bin
|
|
13
14
|
cert_chain: []
|
|
14
|
-
date:
|
|
15
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
|
15
16
|
dependencies:
|
|
16
17
|
- !ruby/object:Gem::Dependency
|
|
17
18
|
name: activerecord
|
|
@@ -19,28 +20,28 @@ dependencies:
|
|
|
19
20
|
requirements:
|
|
20
21
|
- - ">="
|
|
21
22
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
23
|
+
version: 6.1.5
|
|
23
24
|
type: :runtime
|
|
24
25
|
prerelease: false
|
|
25
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
27
|
requirements:
|
|
27
28
|
- - ">="
|
|
28
29
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
30
|
+
version: 6.1.5
|
|
30
31
|
- !ruby/object:Gem::Dependency
|
|
31
32
|
name: activesupport
|
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
|
33
34
|
requirements:
|
|
34
35
|
- - ">="
|
|
35
36
|
- !ruby/object:Gem::Version
|
|
36
|
-
version:
|
|
37
|
+
version: 6.1.5
|
|
37
38
|
type: :runtime
|
|
38
39
|
prerelease: false
|
|
39
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
41
|
requirements:
|
|
41
42
|
- - ">="
|
|
42
43
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
44
|
+
version: 6.1.5
|
|
44
45
|
- !ruby/object:Gem::Dependency
|
|
45
46
|
name: i18n
|
|
46
47
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -69,9 +70,12 @@ files:
|
|
|
69
70
|
- ".github/FUNDING.yml"
|
|
70
71
|
- ".github/SECURITY.md"
|
|
71
72
|
- ".github/workflows/cronjob.yml"
|
|
73
|
+
- ".github/workflows/deploy.yml"
|
|
72
74
|
- ".github/workflows/rubocop.yml"
|
|
75
|
+
- ".github/workflows/test-deploy.yml"
|
|
73
76
|
- ".github/workflows/test.yml"
|
|
74
77
|
- ".gitignore"
|
|
78
|
+
- ".nojekyll"
|
|
75
79
|
- ".rubocop.yml"
|
|
76
80
|
- CHANGELOG.md
|
|
77
81
|
- CONTRIBUTING.md
|
|
@@ -81,20 +85,70 @@ files:
|
|
|
81
85
|
- Rakefile
|
|
82
86
|
- bug_report_templates/test-ransack-scope-and-column-same-name.rb
|
|
83
87
|
- bug_report_templates/test-ransacker-arel-present-predicate.rb
|
|
84
|
-
- docs
|
|
85
|
-
- docs
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
88
|
+
- docs/.gitignore
|
|
89
|
+
- docs/.nojekyll
|
|
90
|
+
- docs/babel.config.js
|
|
91
|
+
- docs/blog/2022-03-27-ransack-3.0.0.md
|
|
92
|
+
- docs/docs/getting-started/_category_.json
|
|
93
|
+
- docs/docs/getting-started/advanced-mode.md
|
|
94
|
+
- docs/docs/getting-started/configuration.md
|
|
95
|
+
- docs/docs/getting-started/search-matches.md
|
|
96
|
+
- docs/docs/getting-started/simple-mode.md
|
|
97
|
+
- docs/docs/getting-started/sorting.md
|
|
98
|
+
- docs/docs/getting-started/using-predicates.md
|
|
99
|
+
- docs/docs/going-further/_category_.json
|
|
100
|
+
- docs/docs/going-further/acts-as-taggable-on.md
|
|
101
|
+
- docs/docs/going-further/associations.md
|
|
102
|
+
- docs/docs/going-further/custom-predicates.md
|
|
103
|
+
- docs/docs/going-further/documentation.md
|
|
104
|
+
- docs/docs/going-further/exporting-to-csv.md
|
|
105
|
+
- docs/docs/going-further/external-guides.md
|
|
106
|
+
- docs/docs/going-further/form-customisation.md
|
|
107
|
+
- docs/docs/going-further/i18n.md
|
|
108
|
+
- docs/docs/going-further/img/create_release.png
|
|
109
|
+
- docs/docs/going-further/merging-searches.md
|
|
110
|
+
- docs/docs/going-further/other-notes.md
|
|
111
|
+
- docs/docs/going-further/polymorphic-search.md
|
|
112
|
+
- docs/docs/going-further/ransackers.md
|
|
113
|
+
- docs/docs/going-further/release_process.md
|
|
114
|
+
- docs/docs/going-further/saving-queries.md
|
|
115
|
+
- docs/docs/going-further/searching-postgres.md
|
|
116
|
+
- docs/docs/going-further/wiki-contributors.md
|
|
117
|
+
- docs/docs/intro.md
|
|
118
|
+
- docs/docusaurus.config.js
|
|
119
|
+
- docs/package.json
|
|
120
|
+
- docs/sidebars.js
|
|
121
|
+
- docs/src/components/HomepageFeatures/index.js
|
|
122
|
+
- docs/src/components/HomepageFeatures/styles.module.css
|
|
123
|
+
- docs/src/css/custom.css
|
|
124
|
+
- docs/src/pages/index.module.css
|
|
125
|
+
- docs/src/pages/markdown-page.md
|
|
126
|
+
- docs/static/.nojekyll
|
|
127
|
+
- docs/static/img/docusaurus.png
|
|
128
|
+
- docs/static/img/favicon.ico
|
|
129
|
+
- docs/static/img/logo.svg
|
|
130
|
+
- docs/static/img/tutorial/docsVersionDropdown.png
|
|
131
|
+
- docs/static/img/tutorial/localeDropdown.png
|
|
132
|
+
- docs/static/img/undraw_docusaurus_mountain.svg
|
|
133
|
+
- docs/static/img/undraw_docusaurus_react.svg
|
|
134
|
+
- docs/static/img/undraw_docusaurus_tree.svg
|
|
135
|
+
- docs/static/logo/ransack-h.png
|
|
136
|
+
- docs/static/logo/ransack-h.svg
|
|
137
|
+
- docs/static/logo/ransack-v.png
|
|
138
|
+
- docs/static/logo/ransack-v.svg
|
|
139
|
+
- docs/static/logo/ransack.png
|
|
140
|
+
- docs/static/logo/ransack.svg
|
|
141
|
+
- docs/yarn.lock
|
|
142
|
+
- lib/polyamorous.rb
|
|
92
143
|
- lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb
|
|
93
144
|
- lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb
|
|
94
145
|
- lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb
|
|
95
|
-
- lib/polyamorous/
|
|
96
|
-
- lib/polyamorous/
|
|
97
|
-
- lib/polyamorous/
|
|
146
|
+
- lib/polyamorous/activerecord_7.0_ruby_2/join_association.rb
|
|
147
|
+
- lib/polyamorous/activerecord_7.0_ruby_2/join_dependency.rb
|
|
148
|
+
- lib/polyamorous/activerecord_7.0_ruby_2/reflection.rb
|
|
149
|
+
- lib/polyamorous/activerecord_7.1_ruby_2/join_association.rb
|
|
150
|
+
- lib/polyamorous/activerecord_7.1_ruby_2/join_dependency.rb
|
|
151
|
+
- lib/polyamorous/activerecord_7.1_ruby_2/reflection.rb
|
|
98
152
|
- lib/polyamorous/join.rb
|
|
99
153
|
- lib/polyamorous/polyamorous.rb
|
|
100
154
|
- lib/polyamorous/swapping_reflection_class.rb
|
|
@@ -137,6 +191,7 @@ files:
|
|
|
137
191
|
- lib/ransack/locale/ro.yml
|
|
138
192
|
- lib/ransack/locale/ru.yml
|
|
139
193
|
- lib/ransack/locale/sk.yml
|
|
194
|
+
- lib/ransack/locale/sv.yml
|
|
140
195
|
- lib/ransack/locale/tr.yml
|
|
141
196
|
- lib/ransack/locale/zh-CN.yml
|
|
142
197
|
- lib/ransack/locale/zh-TW.yml
|
|
@@ -155,12 +210,6 @@ files:
|
|
|
155
210
|
- lib/ransack/translate.rb
|
|
156
211
|
- lib/ransack/version.rb
|
|
157
212
|
- lib/ransack/visitor.rb
|
|
158
|
-
- logo/ransack-h.png
|
|
159
|
-
- logo/ransack-h.svg
|
|
160
|
-
- logo/ransack-v.png
|
|
161
|
-
- logo/ransack-v.svg
|
|
162
|
-
- logo/ransack.png
|
|
163
|
-
- logo/ransack.svg
|
|
164
213
|
- ransack.gemspec
|
|
165
214
|
- spec/blueprints/articles.rb
|
|
166
215
|
- spec/blueprints/comments.rb
|
|
@@ -170,6 +219,7 @@ files:
|
|
|
170
219
|
- spec/console.rb
|
|
171
220
|
- spec/helpers/polyamorous_helper.rb
|
|
172
221
|
- spec/helpers/ransack_helper.rb
|
|
222
|
+
- spec/polyamorous/activerecord_compatibility_spec.rb
|
|
173
223
|
- spec/polyamorous/join_association_spec.rb
|
|
174
224
|
- spec/polyamorous/join_dependency_spec.rb
|
|
175
225
|
- spec/polyamorous/join_spec.rb
|
|
@@ -180,6 +230,7 @@ files:
|
|
|
180
230
|
- spec/ransack/helpers/form_helper_spec.rb
|
|
181
231
|
- spec/ransack/nodes/condition_spec.rb
|
|
182
232
|
- spec/ransack/nodes/grouping_spec.rb
|
|
233
|
+
- spec/ransack/nodes/value_spec.rb
|
|
183
234
|
- spec/ransack/predicate_spec.rb
|
|
184
235
|
- spec/ransack/search_spec.rb
|
|
185
236
|
- spec/ransack/translate_spec.rb
|
|
@@ -190,7 +241,7 @@ homepage: https://github.com/activerecord-hackery/ransack
|
|
|
190
241
|
licenses:
|
|
191
242
|
- MIT
|
|
192
243
|
metadata: {}
|
|
193
|
-
post_install_message:
|
|
244
|
+
post_install_message:
|
|
194
245
|
rdoc_options: []
|
|
195
246
|
require_paths:
|
|
196
247
|
- lib
|
|
@@ -198,17 +249,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
198
249
|
requirements:
|
|
199
250
|
- - ">="
|
|
200
251
|
- !ruby/object:Gem::Version
|
|
201
|
-
version: '2.
|
|
252
|
+
version: '2.7'
|
|
202
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
254
|
requirements:
|
|
204
255
|
- - ">="
|
|
205
256
|
- !ruby/object:Gem::Version
|
|
206
257
|
version: '0'
|
|
207
258
|
requirements: []
|
|
208
|
-
rubygems_version: 3.
|
|
209
|
-
signing_key:
|
|
259
|
+
rubygems_version: 3.3.14
|
|
260
|
+
signing_key:
|
|
210
261
|
specification_version: 4
|
|
211
|
-
summary: Object-based searching for Active Record
|
|
262
|
+
summary: Object-based searching for Active Record.
|
|
212
263
|
test_files:
|
|
213
264
|
- spec/blueprints/articles.rb
|
|
214
265
|
- spec/blueprints/comments.rb
|
|
@@ -218,6 +269,7 @@ test_files:
|
|
|
218
269
|
- spec/console.rb
|
|
219
270
|
- spec/helpers/polyamorous_helper.rb
|
|
220
271
|
- spec/helpers/ransack_helper.rb
|
|
272
|
+
- spec/polyamorous/activerecord_compatibility_spec.rb
|
|
221
273
|
- spec/polyamorous/join_association_spec.rb
|
|
222
274
|
- spec/polyamorous/join_dependency_spec.rb
|
|
223
275
|
- spec/polyamorous/join_spec.rb
|
|
@@ -228,6 +280,7 @@ test_files:
|
|
|
228
280
|
- spec/ransack/helpers/form_helper_spec.rb
|
|
229
281
|
- spec/ransack/nodes/condition_spec.rb
|
|
230
282
|
- spec/ransack/nodes/grouping_spec.rb
|
|
283
|
+
- spec/ransack/nodes/value_spec.rb
|
|
231
284
|
- spec/ransack/predicate_spec.rb
|
|
232
285
|
- spec/ransack/search_spec.rb
|
|
233
286
|
- spec/ransack/translate_spec.rb
|
data/docs/release_process.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
## Release Process
|
|
2
|
-
|
|
3
|
-
*For maintainers of Ransack.*
|
|
4
|
-
|
|
5
|
-
To release a new version of Ransack and publish it to RubyGems, take the following steps:
|
|
6
|
-
|
|
7
|
-
- Create a new release, marked `Prerelease`.
|
|
8
|
-
<<<<<<< Updated upstream
|
|
9
|
-
- Update the versions file to the new release, commit and push to `master`.
|
|
10
|
-
=======
|
|
11
|
-
- Update the [version.rb](../lib/ransack/version.rb) file to the new release, commit and push to `master`.
|
|
12
|
-
>>>>>>> Stashed changes
|
|
13
|
-
- From the terminal, run the following commands
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
rake build
|
|
17
|
-
rake release
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-

|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Polyamorous
|
|
2
|
-
module JoinAssociationExtensions
|
|
3
|
-
include SwappingReflectionClass
|
|
4
|
-
def self.prepended(base)
|
|
5
|
-
base.class_eval { attr_reader :join_type }
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin)
|
|
9
|
-
@join_type = join_type
|
|
10
|
-
if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
|
|
11
|
-
swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
|
|
12
|
-
super(reflection, children)
|
|
13
|
-
self.reflection.options[:polymorphic] = true
|
|
14
|
-
end
|
|
15
|
-
else
|
|
16
|
-
super(reflection, children)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def ==(other)
|
|
21
|
-
base_klass == other.base_klass
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
module Polyamorous
|
|
2
|
-
module JoinDependencyExtensions
|
|
3
|
-
# Replaces ActiveRecord::Associations::JoinDependency#build
|
|
4
|
-
def build(associations, base_klass)
|
|
5
|
-
associations.map do |name, right|
|
|
6
|
-
if name.is_a? Join
|
|
7
|
-
reflection = find_reflection base_klass, name.name
|
|
8
|
-
reflection.check_validity!
|
|
9
|
-
reflection.check_eager_loadable!
|
|
10
|
-
|
|
11
|
-
klass = if reflection.polymorphic?
|
|
12
|
-
name.klass || base_klass
|
|
13
|
-
else
|
|
14
|
-
reflection.klass
|
|
15
|
-
end
|
|
16
|
-
JoinAssociation.new(reflection, build(right, klass), name.klass, name.type)
|
|
17
|
-
else
|
|
18
|
-
reflection = find_reflection base_klass, name
|
|
19
|
-
reflection.check_validity!
|
|
20
|
-
reflection.check_eager_loadable!
|
|
21
|
-
|
|
22
|
-
if reflection.polymorphic?
|
|
23
|
-
raise ActiveRecord::EagerLoadPolymorphicError.new(reflection)
|
|
24
|
-
end
|
|
25
|
-
JoinAssociation.new(reflection, build(right, reflection.klass))
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def join_constraints(joins_to_add, join_type, alias_tracker)
|
|
31
|
-
@alias_tracker = alias_tracker
|
|
32
|
-
|
|
33
|
-
construct_tables!(join_root)
|
|
34
|
-
joins = make_join_constraints(join_root, join_type)
|
|
35
|
-
|
|
36
|
-
joins.concat joins_to_add.flat_map { |oj|
|
|
37
|
-
construct_tables!(oj.join_root)
|
|
38
|
-
if join_root.match?(oj.join_root) && join_root.table.name == oj.join_root.table.name
|
|
39
|
-
walk join_root, oj.join_root
|
|
40
|
-
else
|
|
41
|
-
make_join_constraints(oj.join_root, join_type)
|
|
42
|
-
end
|
|
43
|
-
}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
def make_constraints(parent, child, join_type = Arel::Nodes::OuterJoin)
|
|
48
|
-
foreign_table = parent.table
|
|
49
|
-
foreign_klass = parent.base_klass
|
|
50
|
-
join_type = child.join_type || join_type if join_type == Arel::Nodes::InnerJoin
|
|
51
|
-
joins = child.join_constraints(foreign_table, foreign_klass, join_type, alias_tracker)
|
|
52
|
-
joins.concat child.children.flat_map { |c| make_constraints(child, c, join_type) }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
module ClassMethods
|
|
56
|
-
# Prepended before ActiveRecord::Associations::JoinDependency#walk_tree
|
|
57
|
-
#
|
|
58
|
-
def walk_tree(associations, hash)
|
|
59
|
-
case associations
|
|
60
|
-
when TreeNode
|
|
61
|
-
associations.add_to_tree(hash)
|
|
62
|
-
when Hash
|
|
63
|
-
associations.each do |k, v|
|
|
64
|
-
cache =
|
|
65
|
-
if TreeNode === k
|
|
66
|
-
k.add_to_tree(hash)
|
|
67
|
-
else
|
|
68
|
-
hash[k] ||= {}
|
|
69
|
-
end
|
|
70
|
-
walk_tree(v, cache)
|
|
71
|
-
end
|
|
72
|
-
else
|
|
73
|
-
super(associations, hash)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'polyamorous/activerecord_5.2_ruby_2/join_association'
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# active_record_6.0_ruby_2/join_dependency.rb
|
|
2
|
-
module Polyamorous
|
|
3
|
-
module JoinDependencyExtensions
|
|
4
|
-
# Replaces ActiveRecord::Associations::JoinDependency#build
|
|
5
|
-
def build(associations, base_klass)
|
|
6
|
-
associations.map do |name, right|
|
|
7
|
-
if name.is_a? Join
|
|
8
|
-
reflection = find_reflection base_klass, name.name
|
|
9
|
-
reflection.check_validity!
|
|
10
|
-
reflection.check_eager_loadable!
|
|
11
|
-
|
|
12
|
-
klass = if reflection.polymorphic?
|
|
13
|
-
name.klass || base_klass
|
|
14
|
-
else
|
|
15
|
-
reflection.klass
|
|
16
|
-
end
|
|
17
|
-
JoinAssociation.new(reflection, build(right, klass), name.klass, name.type)
|
|
18
|
-
else
|
|
19
|
-
reflection = find_reflection base_klass, name
|
|
20
|
-
reflection.check_validity!
|
|
21
|
-
reflection.check_eager_loadable!
|
|
22
|
-
|
|
23
|
-
if reflection.polymorphic?
|
|
24
|
-
raise ActiveRecord::EagerLoadPolymorphicError.new(reflection)
|
|
25
|
-
end
|
|
26
|
-
JoinAssociation.new(reflection, build(right, reflection.klass))
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def join_constraints(joins_to_add, alias_tracker)
|
|
32
|
-
@alias_tracker = alias_tracker
|
|
33
|
-
|
|
34
|
-
construct_tables!(join_root)
|
|
35
|
-
joins = make_join_constraints(join_root, join_type)
|
|
36
|
-
|
|
37
|
-
joins.concat joins_to_add.flat_map { |oj|
|
|
38
|
-
construct_tables!(oj.join_root)
|
|
39
|
-
if join_root.match?(oj.join_root) && join_root.table.name == oj.join_root.table.name
|
|
40
|
-
walk join_root, oj.join_root, oj.join_type
|
|
41
|
-
else
|
|
42
|
-
make_join_constraints(oj.join_root, oj.join_type)
|
|
43
|
-
end
|
|
44
|
-
}
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
def make_constraints(parent, child, join_type = Arel::Nodes::OuterJoin)
|
|
49
|
-
foreign_table = parent.table
|
|
50
|
-
foreign_klass = parent.base_klass
|
|
51
|
-
join_type = child.join_type || join_type if join_type == Arel::Nodes::InnerJoin
|
|
52
|
-
joins = child.join_constraints(foreign_table, foreign_klass, join_type, alias_tracker)
|
|
53
|
-
joins.concat child.children.flat_map { |c| make_constraints(child, c, join_type) }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
module ClassMethods
|
|
57
|
-
# Prepended before ActiveRecord::Associations::JoinDependency#walk_tree
|
|
58
|
-
#
|
|
59
|
-
def walk_tree(associations, hash)
|
|
60
|
-
case associations
|
|
61
|
-
when TreeNode
|
|
62
|
-
associations.add_to_tree(hash)
|
|
63
|
-
when Hash
|
|
64
|
-
associations.each do |k, v|
|
|
65
|
-
cache =
|
|
66
|
-
if TreeNode === k
|
|
67
|
-
k.add_to_tree(hash)
|
|
68
|
-
else
|
|
69
|
-
hash[k] ||= {}
|
|
70
|
-
end
|
|
71
|
-
walk_tree(v, cache)
|
|
72
|
-
end
|
|
73
|
-
else
|
|
74
|
-
super(associations, hash)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'polyamorous/activerecord_5.2_ruby_2/reflection'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/join_association.rb
RENAMED
|
File without changes
|
/data/lib/polyamorous/{activerecord_6.2_ruby_2 → activerecord_7.0_ruby_2}/join_dependency.rb
RENAMED
|
File without changes
|
|
File without changes
|