ransack 2.3.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) 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 +263 -1
  13. data/CONTRIBUTING.md +51 -29
  14. data/Gemfile +24 -10
  15. data/README.md +49 -917
  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_6.1_ruby_2/join_association.rb +70 -0
  67. data/{polyamorous/lib/polyamorous/activerecord_6.0_ruby_2 → lib/polyamorous/activerecord_6.1_ruby_2}/join_dependency.rb +33 -12
  68. data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -0
  69. data/lib/polyamorous/activerecord_7.0_ruby_2/join_association.rb +1 -0
  70. data/lib/polyamorous/activerecord_7.0_ruby_2/join_dependency.rb +1 -0
  71. data/lib/polyamorous/activerecord_7.0_ruby_2/reflection.rb +1 -0
  72. data/lib/polyamorous/activerecord_7.1_ruby_2/join_association.rb +1 -0
  73. data/lib/polyamorous/activerecord_7.1_ruby_2/join_dependency.rb +1 -0
  74. data/lib/polyamorous/activerecord_7.1_ruby_2/reflection.rb +1 -0
  75. data/{polyamorous/lib → lib/polyamorous}/polyamorous.rb +3 -8
  76. data/lib/ransack/adapters/active_record/base.rb +83 -10
  77. data/lib/ransack/adapters/active_record/context.rb +61 -116
  78. data/lib/ransack/configuration.rb +53 -10
  79. data/lib/ransack/constants.rb +126 -7
  80. data/lib/ransack/context.rb +34 -5
  81. data/lib/ransack/helpers/form_builder.rb +11 -17
  82. data/lib/ransack/helpers/form_helper.rb +14 -5
  83. data/lib/ransack/helpers.rb +1 -1
  84. data/lib/ransack/locale/sk.yml +70 -0
  85. data/lib/ransack/locale/sv.yml +70 -0
  86. data/lib/ransack/nodes/attribute.rb +3 -3
  87. data/lib/ransack/nodes/condition.rb +87 -8
  88. data/lib/ransack/nodes/grouping.rb +4 -4
  89. data/lib/ransack/nodes/node.rb +1 -1
  90. data/lib/ransack/nodes/sort.rb +3 -3
  91. data/lib/ransack/nodes/value.rb +3 -3
  92. data/lib/ransack/predicate.rb +3 -2
  93. data/lib/ransack/ransacker.rb +1 -1
  94. data/lib/ransack/search.rb +15 -7
  95. data/lib/ransack/translate.rb +6 -6
  96. data/lib/ransack/version.rb +1 -1
  97. data/lib/ransack/visitor.rb +38 -2
  98. data/lib/ransack.rb +6 -10
  99. data/ransack.gemspec +9 -24
  100. data/spec/blueprints/articles.rb +1 -1
  101. data/spec/blueprints/comments.rb +1 -1
  102. data/spec/blueprints/notes.rb +1 -1
  103. data/spec/blueprints/tags.rb +1 -1
  104. data/spec/console.rb +5 -5
  105. data/spec/helpers/polyamorous_helper.rb +2 -17
  106. data/spec/helpers/ransack_helper.rb +1 -1
  107. data/spec/polyamorous/activerecord_compatibility_spec.rb +15 -0
  108. data/spec/{ransack → polyamorous}/join_association_spec.rb +3 -1
  109. data/spec/{ransack → polyamorous}/join_dependency_spec.rb +0 -16
  110. data/spec/ransack/adapters/active_record/base_spec.rb +125 -16
  111. data/spec/ransack/adapters/active_record/context_spec.rb +19 -18
  112. data/spec/ransack/configuration_spec.rb +33 -9
  113. data/spec/ransack/helpers/form_builder_spec.rb +8 -8
  114. data/spec/ransack/helpers/form_helper_spec.rb +109 -20
  115. data/spec/ransack/nodes/condition_spec.rb +37 -0
  116. data/spec/ransack/nodes/grouping_spec.rb +2 -2
  117. data/spec/ransack/nodes/value_spec.rb +115 -0
  118. data/spec/ransack/predicate_spec.rb +75 -2
  119. data/spec/ransack/search_spec.rb +239 -38
  120. data/spec/ransack/translate_spec.rb +1 -1
  121. data/spec/spec_helper.rb +9 -5
  122. data/spec/support/schema.rb +111 -12
  123. metadata +105 -195
  124. data/.travis.yml +0 -49
  125. data/lib/ransack/adapters/active_record/ransack/constants.rb +0 -116
  126. data/lib/ransack/adapters/active_record/ransack/context.rb +0 -60
  127. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +0 -61
  128. data/lib/ransack/adapters/active_record/ransack/translate.rb +0 -8
  129. data/lib/ransack/adapters/active_record/ransack/visitor.rb +0 -47
  130. data/lib/ransack/adapters.rb +0 -64
  131. data/lib/ransack/nodes.rb +0 -8
  132. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +0 -2
  133. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +0 -2
  134. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +0 -31
  135. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +0 -112
  136. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +0 -31
  137. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +0 -112
  138. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb +0 -12
  139. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb +0 -22
  140. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb +0 -81
  141. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb +0 -2
  142. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -2
  143. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -2
  144. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -2
  145. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -2
  146. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +0 -2
  147. data/polyamorous/lib/polyamorous/version.rb +0 -3
  148. data/polyamorous/polyamorous.gemspec +0 -35
  149. /data/{logo → docs/static/logo}/ransack-h.png +0 -0
  150. /data/{logo → docs/static/logo}/ransack-h.svg +0 -0
  151. /data/{logo → docs/static/logo}/ransack-v.png +0 -0
  152. /data/{logo → docs/static/logo}/ransack-v.svg +0 -0
  153. /data/{logo → docs/static/logo}/ransack.png +0 -0
  154. /data/{logo → docs/static/logo}/ransack.svg +0 -0
  155. /data/{polyamorous/lib → lib}/polyamorous/join.rb +0 -0
  156. /data/{polyamorous/lib → lib}/polyamorous/swapping_reflection_class.rb +0 -0
  157. /data/{polyamorous/lib → lib}/polyamorous/tree_node.rb +0 -0
  158. /data/lib/ransack/{adapters/active_record.rb → active_record.rb} +0 -0
  159. /data/spec/{ransack → polyamorous}/join_spec.rb +0 -0
@@ -1,22 +0,0 @@
1
- # active_record_5.2.1_ruby_2/join_association.rb
2
-
3
- module Polyamorous
4
- module JoinAssociationExtensions
5
- include SwappingReflectionClass
6
- def self.prepended(base)
7
- base.class_eval { attr_reader :join_type }
8
- end
9
-
10
- def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin)
11
- @join_type = join_type
12
- if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
13
- swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
14
- super(reflection, children)
15
- self.reflection.options[:polymorphic] = true
16
- end
17
- else
18
- super(reflection, children)
19
- end
20
- end
21
- end
22
- end
@@ -1,81 +0,0 @@
1
- # active_record_5.2.1_ruby_2/join_dependency.rb
2
-
3
- module Polyamorous
4
- module JoinDependencyExtensions
5
- # Replaces ActiveRecord::Associations::JoinDependency#build
6
- def build(associations, base_klass)
7
- associations.map do |name, right|
8
- if name.is_a? Join
9
- reflection = find_reflection base_klass, name.name
10
- reflection.check_validity!
11
- reflection.check_eager_loadable!
12
-
13
- klass = if reflection.polymorphic?
14
- name.klass || base_klass
15
- else
16
- reflection.klass
17
- end
18
- JoinAssociation.new(reflection, build(right, klass), name.klass, name.type)
19
- else
20
- reflection = find_reflection base_klass, name
21
- reflection.check_validity!
22
- reflection.check_eager_loadable!
23
-
24
- if reflection.polymorphic?
25
- raise ActiveRecord::EagerLoadPolymorphicError.new(reflection)
26
- end
27
- JoinAssociation.new(reflection, build(right, reflection.klass))
28
- end
29
- end
30
- end
31
-
32
- def join_constraints(joins_to_add, join_type, alias_tracker)
33
- @alias_tracker = alias_tracker
34
-
35
- construct_tables!(join_root)
36
- joins = make_join_constraints(join_root, join_type)
37
-
38
- joins.concat joins_to_add.flat_map { |oj|
39
- construct_tables!(oj.join_root)
40
- if join_root.match?(oj.join_root) && join_root.table.name == oj.join_root.table.name
41
- walk join_root, oj.join_root
42
- else
43
- make_join_constraints(oj.join_root, join_type)
44
- end
45
- }
46
- end
47
-
48
- private
49
- def make_constraints(parent, child, join_type = Arel::Nodes::OuterJoin)
50
- foreign_table = parent.table
51
- foreign_klass = parent.base_klass
52
- join_type = child.join_type || join_type if join_type == Arel::Nodes::InnerJoin
53
- joins = child.join_constraints(foreign_table, foreign_klass, join_type, alias_tracker)
54
- joins.concat child.children.flat_map { |c| make_constraints(child, c, join_type) }
55
- end
56
-
57
- module ClassMethods
58
- # Prepended before ActiveRecord::Associations::JoinDependency#walk_tree
59
- #
60
- def walk_tree(associations, hash)
61
- case associations
62
- when TreeNode
63
- associations.add_to_tree(hash)
64
- when Hash
65
- associations.each do |k, v|
66
- cache =
67
- if TreeNode === k
68
- k.add_to_tree(hash)
69
- else
70
- hash[k] ||= {}
71
- end
72
- walk_tree(v, cache)
73
- end
74
- else
75
- super(associations, hash)
76
- end
77
- end
78
- end
79
-
80
- end
81
- end
@@ -1,2 +0,0 @@
1
- # active_record_5.2.1_ruby_2/reflection.rb
2
- require 'polyamorous/activerecord_5.2.0_ruby_2/reflection'
@@ -1,2 +0,0 @@
1
- # active_record_6.0_ruby_2/join_association
2
- require 'polyamorous/activerecord_5.2.1_ruby_2/join_association'
@@ -1,2 +0,0 @@
1
- # active_record_6.0_ruby_2/reflection.rb
2
- require 'polyamorous/activerecord_5.2.0_ruby_2/reflection'
@@ -1,2 +0,0 @@
1
- # active_record_6.1_ruby_2/join_association
2
- require 'polyamorous/activerecord_6.0_ruby_2/join_association'
@@ -1,2 +0,0 @@
1
- # active_record_6.1_ruby_2/join_dependency.rb
2
- require 'polyamorous/activerecord_6.0_ruby_2/join_dependency'
@@ -1,2 +0,0 @@
1
- # active_record_6.1_ruby_2/reflection.rb
2
- require 'polyamorous/activerecord_6.0_ruby_2/reflection'
@@ -1,3 +0,0 @@
1
- module Polyamorous
2
- VERSION = '2.3.0'
3
- end
@@ -1,35 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "polyamorous/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "polyamorous"
7
- s.version = Polyamorous::VERSION
8
- s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack", "Xiang Li"]
9
- s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com", "bigxiang@gmail.com"]
10
- s.homepage = "https://github.com/activerecord-hackery/ransack/tree/master/polyamorous"
11
- s.license = "MIT"
12
- s.summary = %q{
13
- Loves/is loved by polymorphic belongs_to associations, Ransack, Squeel, MetaSearch...
14
- }
15
- s.description = %q{
16
- This is just an extraction from Ransack/Squeel. You probably don't want to use this
17
- directly. It extends ActiveRecord's associations to support polymorphic belongs_to
18
- associations.
19
- }
20
-
21
- s.add_dependency 'activerecord', '>= 5.0'
22
- s.add_development_dependency 'rspec', '~> 3'
23
- s.add_development_dependency 'machinist', '~> 1.0.6'
24
- s.add_development_dependency 'faker', '~> 1.6.5'
25
- s.add_development_dependency 'sqlite3', '~> 1.3.3'
26
-
27
- s.files = `git ls-files`.split("\n")
28
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
- s.require_paths = ["lib"]
31
-
32
- # specify any dependencies here; for example:
33
- # s.add_development_dependency "rspec"
34
- # s.add_runtime_dependency "rest-client"
35
- end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes