ransack 2.3.2 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/SECURITY.md +12 -0
  4. data/.github/workflows/codeql.yml +72 -0
  5. data/.github/workflows/cronjob.yml +99 -0
  6. data/.github/workflows/deploy.yml +35 -0
  7. data/.github/workflows/rubocop.yml +20 -0
  8. data/.github/workflows/test-deploy.yml +29 -0
  9. data/.github/workflows/test.yml +131 -0
  10. data/.nojekyll +0 -0
  11. data/.rubocop.yml +50 -0
  12. data/CHANGELOG.md +251 -1
  13. data/CONTRIBUTING.md +51 -29
  14. data/Gemfile +12 -10
  15. data/README.md +45 -907
  16. data/bug_report_templates/test-ransack-scope-and-column-same-name.rb +78 -0
  17. data/bug_report_templates/test-ransacker-arel-present-predicate.rb +75 -0
  18. data/docs/.gitignore +19 -0
  19. data/docs/.nojekyll +0 -0
  20. data/docs/babel.config.js +3 -0
  21. data/docs/blog/2022-03-27-ransack-3.0.0.md +20 -0
  22. data/docs/docs/getting-started/_category_.json +4 -0
  23. data/docs/docs/getting-started/advanced-mode.md +46 -0
  24. data/docs/docs/getting-started/configuration.md +47 -0
  25. data/docs/docs/getting-started/search-matches.md +67 -0
  26. data/docs/docs/getting-started/simple-mode.md +288 -0
  27. data/docs/docs/getting-started/sorting.md +71 -0
  28. data/docs/docs/getting-started/using-predicates.md +282 -0
  29. data/docs/docs/going-further/_category_.json +4 -0
  30. data/docs/docs/going-further/acts-as-taggable-on.md +114 -0
  31. data/docs/docs/going-further/associations.md +70 -0
  32. data/docs/docs/going-further/custom-predicates.md +52 -0
  33. data/docs/docs/going-further/documentation.md +43 -0
  34. data/docs/docs/going-further/exporting-to-csv.md +49 -0
  35. data/docs/docs/going-further/external-guides.md +57 -0
  36. data/docs/docs/going-further/form-customisation.md +63 -0
  37. data/docs/docs/going-further/i18n.md +53 -0
  38. data/docs/docs/going-further/img/create_release.png +0 -0
  39. data/docs/docs/going-further/merging-searches.md +41 -0
  40. data/docs/docs/going-further/other-notes.md +428 -0
  41. data/docs/docs/going-further/polymorphic-search.md +46 -0
  42. data/docs/docs/going-further/ransackers.md +331 -0
  43. data/docs/docs/going-further/release_process.md +36 -0
  44. data/docs/docs/going-further/saving-queries.md +82 -0
  45. data/docs/docs/going-further/searching-postgres.md +57 -0
  46. data/docs/docs/going-further/wiki-contributors.md +82 -0
  47. data/docs/docs/intro.md +99 -0
  48. data/docs/docusaurus.config.js +120 -0
  49. data/docs/package.json +42 -0
  50. data/docs/sidebars.js +31 -0
  51. data/docs/src/components/HomepageFeatures/index.js +64 -0
  52. data/docs/src/components/HomepageFeatures/styles.module.css +11 -0
  53. data/docs/src/css/custom.css +39 -0
  54. data/docs/src/pages/index.module.css +23 -0
  55. data/docs/src/pages/markdown-page.md +7 -0
  56. data/docs/static/.nojekyll +0 -0
  57. data/docs/static/img/docusaurus.png +0 -0
  58. data/docs/static/img/favicon.ico +0 -0
  59. data/docs/static/img/logo.svg +1 -0
  60. data/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
  61. data/docs/static/img/tutorial/localeDropdown.png +0 -0
  62. data/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
  63. data/docs/static/img/undraw_docusaurus_react.svg +170 -0
  64. data/docs/static/img/undraw_docusaurus_tree.svg +40 -0
  65. data/docs/yarn.lock +8879 -0
  66. data/lib/polyamorous/activerecord/join_association.rb +70 -0
  67. data/{polyamorous/lib/polyamorous/activerecord_6.0_ruby_2 → lib/polyamorous/activerecord}/join_dependency.rb +33 -12
  68. data/lib/polyamorous/activerecord/reflection.rb +11 -0
  69. data/{polyamorous/lib → lib/polyamorous}/polyamorous.rb +3 -4
  70. data/lib/ransack/adapters/active_record/base.rb +83 -10
  71. data/lib/ransack/adapters/active_record/context.rb +56 -44
  72. data/lib/ransack/configuration.rb +53 -10
  73. data/lib/ransack/constants.rb +126 -4
  74. data/lib/ransack/context.rb +34 -5
  75. data/lib/ransack/helpers/form_builder.rb +6 -6
  76. data/lib/ransack/helpers/form_helper.rb +14 -5
  77. data/lib/ransack/helpers.rb +1 -1
  78. data/lib/ransack/locale/sv.yml +70 -0
  79. data/lib/ransack/nodes/attribute.rb +3 -3
  80. data/lib/ransack/nodes/condition.rb +80 -9
  81. data/lib/ransack/nodes/grouping.rb +4 -4
  82. data/lib/ransack/nodes/node.rb +1 -1
  83. data/lib/ransack/nodes/sort.rb +3 -3
  84. data/lib/ransack/nodes/value.rb +3 -3
  85. data/lib/ransack/predicate.rb +1 -1
  86. data/lib/ransack/ransacker.rb +1 -1
  87. data/lib/ransack/search.rb +15 -7
  88. data/lib/ransack/translate.rb +6 -6
  89. data/lib/ransack/version.rb +1 -1
  90. data/lib/ransack/visitor.rb +38 -2
  91. data/lib/ransack.rb +5 -8
  92. data/ransack.gemspec +9 -15
  93. data/spec/blueprints/articles.rb +1 -1
  94. data/spec/blueprints/comments.rb +1 -1
  95. data/spec/blueprints/notes.rb +1 -1
  96. data/spec/blueprints/tags.rb +1 -1
  97. data/spec/console.rb +5 -5
  98. data/spec/helpers/polyamorous_helper.rb +2 -8
  99. data/spec/helpers/ransack_helper.rb +1 -1
  100. data/spec/polyamorous/activerecord_compatibility_spec.rb +15 -0
  101. data/spec/{ransack → polyamorous}/join_association_spec.rb +3 -1
  102. data/spec/{ransack → polyamorous}/join_dependency_spec.rb +0 -16
  103. data/spec/ransack/adapters/active_record/base_spec.rb +125 -16
  104. data/spec/ransack/adapters/active_record/context_spec.rb +19 -18
  105. data/spec/ransack/configuration_spec.rb +33 -9
  106. data/spec/ransack/helpers/form_builder_spec.rb +8 -8
  107. data/spec/ransack/helpers/form_helper_spec.rb +109 -20
  108. data/spec/ransack/nodes/condition_spec.rb +37 -0
  109. data/spec/ransack/nodes/grouping_spec.rb +2 -2
  110. data/spec/ransack/nodes/value_spec.rb +115 -0
  111. data/spec/ransack/predicate_spec.rb +37 -2
  112. data/spec/ransack/search_spec.rb +238 -30
  113. data/spec/ransack/translate_spec.rb +1 -1
  114. data/spec/spec_helper.rb +7 -5
  115. data/spec/support/schema.rb +108 -11
  116. metadata +98 -62
  117. data/.travis.yml +0 -47
  118. data/lib/ransack/adapters/active_record/ransack/constants.rb +0 -128
  119. data/lib/ransack/adapters/active_record/ransack/context.rb +0 -55
  120. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +0 -61
  121. data/lib/ransack/adapters/active_record/ransack/translate.rb +0 -8
  122. data/lib/ransack/adapters/active_record/ransack/visitor.rb +0 -47
  123. data/lib/ransack/adapters.rb +0 -64
  124. data/lib/ransack/nodes.rb +0 -8
  125. data/polyamorous/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb +0 -20
  126. data/polyamorous/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb +0 -79
  127. data/polyamorous/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +0 -12
  128. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -2
  129. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -2
  130. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -2
  131. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -2
  132. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +0 -2
  133. data/polyamorous/lib/polyamorous/version.rb +0 -3
  134. data/polyamorous/polyamorous.gemspec +0 -27
  135. /data/{logo → docs/static/logo}/ransack-h.png +0 -0
  136. /data/{logo → docs/static/logo}/ransack-h.svg +0 -0
  137. /data/{logo → docs/static/logo}/ransack-v.png +0 -0
  138. /data/{logo → docs/static/logo}/ransack-v.svg +0 -0
  139. /data/{logo → docs/static/logo}/ransack.png +0 -0
  140. /data/{logo → docs/static/logo}/ransack.svg +0 -0
  141. /data/{polyamorous/lib → lib}/polyamorous/join.rb +0 -0
  142. /data/{polyamorous/lib → lib}/polyamorous/swapping_reflection_class.rb +0 -0
  143. /data/{polyamorous/lib → lib}/polyamorous/tree_node.rb +0 -0
  144. /data/lib/ransack/{adapters/active_record.rb → active_record.rb} +0 -0
  145. /data/spec/{ransack → polyamorous}/join_spec.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.3.2
4
+ version: 4.1.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
- autorequire:
11
+ - David Rodríguez
12
+ autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2020-01-11 00:00:00.000000000 Z
15
+ date: 2023-10-29 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: 5.2.1
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: 5.2.1
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: 5.2.1
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: 5.2.1
44
+ version: 6.1.5
44
45
  - !ruby/object:Gem::Dependency
45
46
  name: i18n
46
47
  requirement: !ruby/object:Gem::Requirement
@@ -55,20 +56,6 @@ dependencies:
55
56
  - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: '0'
58
- - !ruby/object:Gem::Dependency
59
- name: polyamorous
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - '='
63
- - !ruby/object:Gem::Version
64
- version: 2.3.2
65
- type: :runtime
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - '='
70
- - !ruby/object:Gem::Version
71
- version: 2.3.2
72
59
  description: Ransack is the successor to the MetaSearch gem. It improves and expands
73
60
  upon MetaSearch's functionality, but does not have a 100%-compatible API.
74
61
  email:
@@ -80,24 +67,90 @@ executables: []
80
67
  extensions: []
81
68
  extra_rdoc_files: []
82
69
  files:
70
+ - ".github/FUNDING.yml"
71
+ - ".github/SECURITY.md"
72
+ - ".github/workflows/codeql.yml"
73
+ - ".github/workflows/cronjob.yml"
74
+ - ".github/workflows/deploy.yml"
75
+ - ".github/workflows/rubocop.yml"
76
+ - ".github/workflows/test-deploy.yml"
77
+ - ".github/workflows/test.yml"
83
78
  - ".gitignore"
84
- - ".travis.yml"
79
+ - ".nojekyll"
80
+ - ".rubocop.yml"
85
81
  - CHANGELOG.md
86
82
  - CONTRIBUTING.md
87
83
  - Gemfile
88
84
  - LICENSE
89
85
  - README.md
90
86
  - Rakefile
87
+ - bug_report_templates/test-ransack-scope-and-column-same-name.rb
88
+ - bug_report_templates/test-ransacker-arel-present-predicate.rb
89
+ - docs/.gitignore
90
+ - docs/.nojekyll
91
+ - docs/babel.config.js
92
+ - docs/blog/2022-03-27-ransack-3.0.0.md
93
+ - docs/docs/getting-started/_category_.json
94
+ - docs/docs/getting-started/advanced-mode.md
95
+ - docs/docs/getting-started/configuration.md
96
+ - docs/docs/getting-started/search-matches.md
97
+ - docs/docs/getting-started/simple-mode.md
98
+ - docs/docs/getting-started/sorting.md
99
+ - docs/docs/getting-started/using-predicates.md
100
+ - docs/docs/going-further/_category_.json
101
+ - docs/docs/going-further/acts-as-taggable-on.md
102
+ - docs/docs/going-further/associations.md
103
+ - docs/docs/going-further/custom-predicates.md
104
+ - docs/docs/going-further/documentation.md
105
+ - docs/docs/going-further/exporting-to-csv.md
106
+ - docs/docs/going-further/external-guides.md
107
+ - docs/docs/going-further/form-customisation.md
108
+ - docs/docs/going-further/i18n.md
109
+ - docs/docs/going-further/img/create_release.png
110
+ - docs/docs/going-further/merging-searches.md
111
+ - docs/docs/going-further/other-notes.md
112
+ - docs/docs/going-further/polymorphic-search.md
113
+ - docs/docs/going-further/ransackers.md
114
+ - docs/docs/going-further/release_process.md
115
+ - docs/docs/going-further/saving-queries.md
116
+ - docs/docs/going-further/searching-postgres.md
117
+ - docs/docs/going-further/wiki-contributors.md
118
+ - docs/docs/intro.md
119
+ - docs/docusaurus.config.js
120
+ - docs/package.json
121
+ - docs/sidebars.js
122
+ - docs/src/components/HomepageFeatures/index.js
123
+ - docs/src/components/HomepageFeatures/styles.module.css
124
+ - docs/src/css/custom.css
125
+ - docs/src/pages/index.module.css
126
+ - docs/src/pages/markdown-page.md
127
+ - docs/static/.nojekyll
128
+ - docs/static/img/docusaurus.png
129
+ - docs/static/img/favicon.ico
130
+ - docs/static/img/logo.svg
131
+ - docs/static/img/tutorial/docsVersionDropdown.png
132
+ - docs/static/img/tutorial/localeDropdown.png
133
+ - docs/static/img/undraw_docusaurus_mountain.svg
134
+ - docs/static/img/undraw_docusaurus_react.svg
135
+ - docs/static/img/undraw_docusaurus_tree.svg
136
+ - docs/static/logo/ransack-h.png
137
+ - docs/static/logo/ransack-h.svg
138
+ - docs/static/logo/ransack-v.png
139
+ - docs/static/logo/ransack-v.svg
140
+ - docs/static/logo/ransack.png
141
+ - docs/static/logo/ransack.svg
142
+ - docs/yarn.lock
143
+ - lib/polyamorous/activerecord/join_association.rb
144
+ - lib/polyamorous/activerecord/join_dependency.rb
145
+ - lib/polyamorous/activerecord/reflection.rb
146
+ - lib/polyamorous/join.rb
147
+ - lib/polyamorous/polyamorous.rb
148
+ - lib/polyamorous/swapping_reflection_class.rb
149
+ - lib/polyamorous/tree_node.rb
91
150
  - lib/ransack.rb
92
- - lib/ransack/adapters.rb
93
- - lib/ransack/adapters/active_record.rb
151
+ - lib/ransack/active_record.rb
94
152
  - lib/ransack/adapters/active_record/base.rb
95
153
  - lib/ransack/adapters/active_record/context.rb
96
- - lib/ransack/adapters/active_record/ransack/constants.rb
97
- - lib/ransack/adapters/active_record/ransack/context.rb
98
- - lib/ransack/adapters/active_record/ransack/nodes/condition.rb
99
- - lib/ransack/adapters/active_record/ransack/translate.rb
100
- - lib/ransack/adapters/active_record/ransack/visitor.rb
101
154
  - lib/ransack/configuration.rb
102
155
  - lib/ransack/constants.rb
103
156
  - lib/ransack/context.rb
@@ -126,11 +179,11 @@ files:
126
179
  - lib/ransack/locale/ro.yml
127
180
  - lib/ransack/locale/ru.yml
128
181
  - lib/ransack/locale/sk.yml
182
+ - lib/ransack/locale/sv.yml
129
183
  - lib/ransack/locale/tr.yml
130
184
  - lib/ransack/locale/zh-CN.yml
131
185
  - lib/ransack/locale/zh-TW.yml
132
186
  - lib/ransack/naming.rb
133
- - lib/ransack/nodes.rb
134
187
  - lib/ransack/nodes/attribute.rb
135
188
  - lib/ransack/nodes/bindable.rb
136
189
  - lib/ransack/nodes/condition.rb
@@ -144,27 +197,6 @@ files:
144
197
  - lib/ransack/translate.rb
145
198
  - lib/ransack/version.rb
146
199
  - lib/ransack/visitor.rb
147
- - logo/ransack-h.png
148
- - logo/ransack-h.svg
149
- - logo/ransack-v.png
150
- - logo/ransack-v.svg
151
- - logo/ransack.png
152
- - logo/ransack.svg
153
- - polyamorous/lib/polyamorous.rb
154
- - polyamorous/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb
155
- - polyamorous/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb
156
- - polyamorous/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb
157
- - polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb
158
- - polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb
159
- - polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb
160
- - polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb
161
- - polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb
162
- - polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb
163
- - polyamorous/lib/polyamorous/join.rb
164
- - polyamorous/lib/polyamorous/swapping_reflection_class.rb
165
- - polyamorous/lib/polyamorous/tree_node.rb
166
- - polyamorous/lib/polyamorous/version.rb
167
- - polyamorous/polyamorous.gemspec
168
200
  - ransack.gemspec
169
201
  - spec/blueprints/articles.rb
170
202
  - spec/blueprints/comments.rb
@@ -174,16 +206,18 @@ files:
174
206
  - spec/console.rb
175
207
  - spec/helpers/polyamorous_helper.rb
176
208
  - spec/helpers/ransack_helper.rb
209
+ - spec/polyamorous/activerecord_compatibility_spec.rb
210
+ - spec/polyamorous/join_association_spec.rb
211
+ - spec/polyamorous/join_dependency_spec.rb
212
+ - spec/polyamorous/join_spec.rb
177
213
  - spec/ransack/adapters/active_record/base_spec.rb
178
214
  - spec/ransack/adapters/active_record/context_spec.rb
179
215
  - spec/ransack/configuration_spec.rb
180
216
  - spec/ransack/helpers/form_builder_spec.rb
181
217
  - spec/ransack/helpers/form_helper_spec.rb
182
- - spec/ransack/join_association_spec.rb
183
- - spec/ransack/join_dependency_spec.rb
184
- - spec/ransack/join_spec.rb
185
218
  - spec/ransack/nodes/condition_spec.rb
186
219
  - spec/ransack/nodes/grouping_spec.rb
220
+ - spec/ransack/nodes/value_spec.rb
187
221
  - spec/ransack/predicate_spec.rb
188
222
  - spec/ransack/search_spec.rb
189
223
  - spec/ransack/translate_spec.rb
@@ -194,7 +228,7 @@ homepage: https://github.com/activerecord-hackery/ransack
194
228
  licenses:
195
229
  - MIT
196
230
  metadata: {}
197
- post_install_message:
231
+ post_install_message:
198
232
  rdoc_options: []
199
233
  require_paths:
200
234
  - lib
@@ -202,17 +236,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
236
  requirements:
203
237
  - - ">="
204
238
  - !ruby/object:Gem::Version
205
- version: '2.3'
239
+ version: '3.0'
206
240
  required_rubygems_version: !ruby/object:Gem::Requirement
207
241
  requirements:
208
242
  - - ">="
209
243
  - !ruby/object:Gem::Version
210
244
  version: '0'
211
245
  requirements: []
212
- rubygems_version: 3.0.3
213
- signing_key:
246
+ rubygems_version: 3.4.10
247
+ signing_key:
214
248
  specification_version: 4
215
- summary: Object-based searching for Active Record and Mongoid (currently).
249
+ summary: Object-based searching for Active Record.
216
250
  test_files:
217
251
  - spec/blueprints/articles.rb
218
252
  - spec/blueprints/comments.rb
@@ -222,16 +256,18 @@ test_files:
222
256
  - spec/console.rb
223
257
  - spec/helpers/polyamorous_helper.rb
224
258
  - spec/helpers/ransack_helper.rb
259
+ - spec/polyamorous/activerecord_compatibility_spec.rb
260
+ - spec/polyamorous/join_association_spec.rb
261
+ - spec/polyamorous/join_dependency_spec.rb
262
+ - spec/polyamorous/join_spec.rb
225
263
  - spec/ransack/adapters/active_record/base_spec.rb
226
264
  - spec/ransack/adapters/active_record/context_spec.rb
227
265
  - spec/ransack/configuration_spec.rb
228
266
  - spec/ransack/helpers/form_builder_spec.rb
229
267
  - spec/ransack/helpers/form_helper_spec.rb
230
- - spec/ransack/join_association_spec.rb
231
- - spec/ransack/join_dependency_spec.rb
232
- - spec/ransack/join_spec.rb
233
268
  - spec/ransack/nodes/condition_spec.rb
234
269
  - spec/ransack/nodes/grouping_spec.rb
270
+ - spec/ransack/nodes/value_spec.rb
235
271
  - spec/ransack/predicate_spec.rb
236
272
  - spec/ransack/search_spec.rb
237
273
  - spec/ransack/translate_spec.rb
data/.travis.yml DELETED
@@ -1,47 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.6.5
5
-
6
- services:
7
- - mysql
8
-
9
- env:
10
- - RAILS=6-0-stable DB=sqlite3
11
- - RAILS=6-0-stable DB=mysql
12
- - RAILS=6-0-stable DB=postgres
13
-
14
- - RAILS=v6.0.0 DB=sqlite3
15
- - RAILS=v6.0.0 DB=mysql
16
- - RAILS=v6.0.0 DB=postgres
17
-
18
- - RAILS=5-2-stable DB=sqlite3
19
- - RAILS=5-2-stable DB=mysql
20
- - RAILS=5-2-stable DB=postgres
21
-
22
- - RAILS=v5.2.3 DB=sqlite3
23
- - RAILS=v5.2.3 DB=mysql
24
- - RAILS=v5.2.3 DB=postgres
25
-
26
- matrix:
27
- allow_failures:
28
- - env: RAILS=6-0-stable DB=sqlite3
29
- - env: RAILS=6-0-stable DB=mysql
30
- - env: RAILS=6-0-stable DB=postgres
31
-
32
- before_script:
33
- - if [ "$DB" = "mysql" ];
34
- then
35
- mysql -e 'create database ransack collate utf8_general_ci;';
36
- mysql -e 'use ransack;show variables like "%character%";show variables like "%collation%";';
37
- fi
38
-
39
- - if [ "$DB" = "postgres" ];
40
- then
41
- psql -c 'create database ransack;' -U postgres;
42
- fi
43
-
44
- addons:
45
- code_climate:
46
- repo_token: 8b701c4364d51a0217105e08c06922d600cec3d9e60d546a89e3ddfe46e0664e
47
- postgresql: "9.6"
@@ -1,128 +0,0 @@
1
- module Ransack
2
- module Constants
3
- DISTINCT = 'DISTINCT '.freeze
4
-
5
- DERIVED_PREDICATES = [
6
- [CONT, {
7
- arel_predicate: 'matches'.freeze,
8
- formatter: proc { |v| "%#{escape_wildcards(v)}%" }
9
- }
10
- ],
11
- ['not_cont'.freeze, {
12
- arel_predicate: 'does_not_match'.freeze,
13
- formatter: proc { |v| "%#{escape_wildcards(v)}%" }
14
- }
15
- ],
16
- ['i_cont'.freeze, {
17
- arel_predicate: 'matches'.freeze,
18
- formatter: proc { |v| "%#{escape_wildcards(v.downcase)}%" },
19
- case_insensitive: true
20
- }
21
- ],
22
- ['not_i_cont'.freeze, {
23
- arel_predicate: 'does_not_match'.freeze,
24
- formatter: proc { |v| "%#{escape_wildcards(v.downcase)}%" },
25
- case_insensitive: true
26
- }
27
- ],
28
- ['start'.freeze, {
29
- arel_predicate: 'matches'.freeze,
30
- formatter: proc { |v| "#{escape_wildcards(v)}%" }
31
- }
32
- ],
33
- ['not_start'.freeze, {
34
- arel_predicate: 'does_not_match'.freeze,
35
- formatter: proc { |v| "#{escape_wildcards(v)}%" }
36
- }
37
- ],
38
- ['end'.freeze, {
39
- arel_predicate: 'matches'.freeze,
40
- formatter: proc { |v| "%#{escape_wildcards(v)}" }
41
- }
42
- ],
43
- ['not_end'.freeze, {
44
- arel_predicate: 'does_not_match'.freeze,
45
- formatter: proc { |v| "%#{escape_wildcards(v)}" }
46
- }
47
- ],
48
- ['true'.freeze, {
49
- arel_predicate: proc { |v| v ? EQ : NOT_EQ },
50
- compounds: false,
51
- type: :boolean,
52
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
53
- formatter: proc { |v| true }
54
- }
55
- ],
56
- ['not_true'.freeze, {
57
- arel_predicate: proc { |v| v ? NOT_EQ : EQ },
58
- compounds: false,
59
- type: :boolean,
60
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
61
- formatter: proc { |v| true }
62
- }
63
- ],
64
- ['false'.freeze, {
65
- arel_predicate: proc { |v| v ? EQ : NOT_EQ },
66
- compounds: false,
67
- type: :boolean,
68
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
69
- formatter: proc { |v| false }
70
- }
71
- ],
72
- ['not_false'.freeze, {
73
- arel_predicate: proc { |v| v ? NOT_EQ : EQ },
74
- compounds: false,
75
- type: :boolean,
76
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
77
- formatter: proc { |v| false }
78
- }
79
- ],
80
- ['present'.freeze, {
81
- arel_predicate: proc { |v| v ? NOT_EQ_ALL : EQ_ANY },
82
- compounds: false,
83
- type: :boolean,
84
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
85
- formatter: proc { |v| [nil, ''.freeze].freeze }
86
- }
87
- ],
88
- ['blank'.freeze, {
89
- arel_predicate: proc { |v| v ? EQ_ANY : NOT_EQ_ALL },
90
- compounds: false,
91
- type: :boolean,
92
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
93
- formatter: proc { |v| [nil, ''.freeze].freeze }
94
- }
95
- ],
96
- ['null'.freeze, {
97
- arel_predicate: proc { |v| v ? EQ : NOT_EQ },
98
- compounds: false,
99
- type: :boolean,
100
- validator: proc { |v| BOOLEAN_VALUES.include?(v)},
101
- formatter: proc { |v| nil }
102
- }
103
- ],
104
- ['not_null'.freeze, {
105
- arel_predicate: proc { |v| v ? NOT_EQ : EQ },
106
- compounds: false,
107
- type: :boolean,
108
- validator: proc { |v| BOOLEAN_VALUES.include?(v) },
109
- formatter: proc { |v| nil } }
110
- ]
111
- ].freeze
112
-
113
- module_function
114
- # replace % \ to \% \\
115
- def escape_wildcards(unescaped)
116
- case ActiveRecord::Base.connection.adapter_name
117
- when "Mysql2".freeze
118
- # Necessary for MySQL
119
- unescaped.to_s.gsub(/([\\%_])/, '\\\\\\1')
120
- when "PostgreSQL".freeze
121
- # Necessary for PostgreSQL
122
- unescaped.to_s.gsub(/([\\%_.])/, '\\\\\\1')
123
- else
124
- unescaped
125
- end
126
- end
127
- end
128
- end
@@ -1,55 +0,0 @@
1
- require 'ransack/visitor'
2
-
3
- module Ransack
4
- class Context
5
- attr_reader :arel_visitor
6
-
7
- class << self
8
-
9
- def for_class(klass, options = {})
10
- if klass < ActiveRecord::Base
11
- Adapters::ActiveRecord::Context.new(klass, options)
12
- end
13
- end
14
-
15
- def for_object(object, options = {})
16
- case object
17
- when ActiveRecord::Relation
18
- Adapters::ActiveRecord::Context.new(object.klass, options)
19
- end
20
- end
21
-
22
- end # << self
23
-
24
- def initialize(object, options = {})
25
- @object = relation_for(object)
26
- @klass = @object.klass
27
- @join_dependency = join_dependency(@object)
28
- @join_type = options[:join_type] || Polyamorous::OuterJoin
29
- @search_key = options[:search_key] || Ransack.options[:search_key]
30
- @associations_pot = {}
31
- @lock_associations = []
32
-
33
- @base = @join_dependency.instance_variable_get(:@join_root)
34
- end
35
-
36
- def bind_pair_for(key)
37
- @bind_pairs ||= {}
38
-
39
- @bind_pairs[key] ||= begin
40
- parent, attr_name = get_parent_and_attribute_name(key.to_s)
41
- [parent, attr_name] if parent && attr_name
42
- end
43
- end
44
-
45
- def klassify(obj)
46
- if Class === obj && ::ActiveRecord::Base > obj
47
- obj
48
- elsif obj.respond_to? :klass
49
- obj.klass
50
- else
51
- raise ArgumentError, "Don't know how to klassify #{obj.inspect}"
52
- end
53
- end
54
- end
55
- end
@@ -1,61 +0,0 @@
1
- module Ransack
2
- module Nodes
3
- class Condition
4
-
5
- def arel_predicate
6
- attributes.map { |attribute|
7
- association = attribute.parent
8
- if negative? && attribute.associated_collection?
9
- query = context.build_correlated_subquery(association)
10
- context.remove_association(association)
11
- if self.predicate_name == 'not_null' && self.value
12
- query.where(format_predicate(attribute))
13
- Arel::Nodes::In.new(context.primary_key, Arel.sql(query.to_sql))
14
- else
15
- query.where(format_predicate(attribute).not)
16
- Arel::Nodes::NotIn.new(context.primary_key, Arel.sql(query.to_sql))
17
- end
18
- else
19
- format_predicate(attribute)
20
- end
21
- }.reduce(combinator_method)
22
- end
23
-
24
- private
25
-
26
- def combinator_method
27
- combinator === Constants::OR ? :or : :and
28
- end
29
-
30
- def format_predicate(attribute)
31
- arel_pred = arel_predicate_for_attribute(attribute)
32
- arel_values = formatted_values_for_attribute(attribute)
33
- predicate = attr_value_for_attribute(attribute).public_send(arel_pred, arel_values)
34
-
35
- if in_predicate?(predicate)
36
- predicate.right = predicate.right.map do |pr|
37
- casted_array?(pr) ? format_values_for(pr) : pr
38
- end
39
- end
40
-
41
- predicate
42
- end
43
-
44
- def in_predicate?(predicate)
45
- return unless defined?(Arel::Nodes::Casted)
46
- predicate.class == Arel::Nodes::In || predicate.class == Arel::Nodes::NotIn
47
- end
48
-
49
- def casted_array?(predicate)
50
- predicate.respond_to?(:val) && predicate.val.is_a?(Array)
51
- end
52
-
53
- def format_values_for(predicate)
54
- predicate.val.map do |value|
55
- value.is_a?(String) ? Arel::Nodes.build_quoted(value) : value
56
- end
57
- end
58
-
59
- end
60
- end
61
- end
@@ -1,8 +0,0 @@
1
- module Ransack
2
- module Translate
3
-
4
- def self.i18n_key(klass)
5
- klass.model_name.i18n_key
6
- end
7
- end
8
- end
@@ -1,47 +0,0 @@
1
- module Ransack
2
- class Visitor
3
- def visit_and(object)
4
- nodes = object.values.map { |o| accept(o) }.compact
5
- return nil unless nodes.size > 0
6
-
7
- if nodes.size > 1
8
- Arel::Nodes::Grouping.new(Arel::Nodes::And.new(nodes))
9
- else
10
- nodes.first
11
- end
12
- end
13
-
14
- def quoted?(object)
15
- case object
16
- when Arel::Nodes::SqlLiteral, Bignum, Fixnum
17
- false
18
- else
19
- true
20
- end
21
- end
22
-
23
- def visit_Ransack_Nodes_Sort(object)
24
- if object.valid?
25
- if object.attr.is_a?(Arel::Attributes::Attribute)
26
- object.attr.send(object.dir)
27
- else
28
- ordered(object)
29
- end
30
- else
31
- scope_name = :"sort_by_#{object.name}_#{object.dir}"
32
- scope_name if object.context.object.respond_to?(scope_name)
33
- end
34
- end
35
-
36
- private
37
-
38
- def ordered(object)
39
- case object.dir
40
- when 'asc'.freeze
41
- Arel::Nodes::Ascending.new(object.attr)
42
- when 'desc'.freeze
43
- Arel::Nodes::Descending.new(object.attr)
44
- end
45
- end
46
- end
47
- end