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
@@ -1,64 +0,0 @@
1
- module Ransack
2
- module Adapters
3
-
4
- def self.object_mapper
5
- @object_mapper ||= instantiate_object_mapper
6
- end
7
-
8
- def self.instantiate_object_mapper
9
- if defined?(::ActiveRecord::Base)
10
- ActiveRecordAdapter.new
11
- elsif defined?(::Mongoid)
12
- MongoidAdapter.new
13
- else
14
- raise "Unsupported adapter"
15
- end
16
- end
17
-
18
- class ActiveRecordAdapter
19
- def require_constants
20
- require 'ransack/adapters/active_record/ransack/constants'
21
- end
22
-
23
- def require_adapter
24
- require 'ransack/adapters/active_record/ransack/translate'
25
- require 'ransack/adapters/active_record'
26
- end
27
-
28
- def require_context
29
- require 'ransack/adapters/active_record/ransack/visitor'
30
- end
31
-
32
- def require_nodes
33
- require 'ransack/adapters/active_record/ransack/nodes/condition'
34
- end
35
-
36
- def require_search
37
- require 'ransack/adapters/active_record/ransack/context'
38
- end
39
- end
40
-
41
- class MongoidAdapter
42
- def require_constants
43
- require 'ransack/adapters/mongoid/ransack/constants'
44
- end
45
-
46
- def require_adapter
47
- require 'ransack/adapters/mongoid/ransack/translate'
48
- require 'ransack/adapters/mongoid'
49
- end
50
-
51
- def require_context
52
- require 'ransack/adapters/mongoid/ransack/visitor'
53
- end
54
-
55
- def require_nodes
56
- require 'ransack/adapters/mongoid/ransack/nodes/condition'
57
- end
58
-
59
- def require_search
60
- require 'ransack/adapters/mongoid/ransack/context'
61
- end
62
- end
63
- end
64
- end
data/lib/ransack/nodes.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'ransack/nodes/bindable'
2
- require 'ransack/nodes/node'
3
- require 'ransack/nodes/attribute'
4
- require 'ransack/nodes/value'
5
- require 'ransack/nodes/condition'
6
- Ransack::Adapters.object_mapper.require_nodes
7
- require 'ransack/nodes/sort'
8
- require 'ransack/nodes/grouping'
@@ -1,20 +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
- end
20
- 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,12 +0,0 @@
1
- module Polyamorous
2
- module ReflectionExtensions
3
- def build_join_constraint(table, foreign_table)
4
- if polymorphic?
5
- super(table, foreign_table)
6
- .and(foreign_table[foreign_type].eq(klass.name))
7
- else
8
- super(table, foreign_table)
9
- end
10
- end
11
- end
12
- end
@@ -1,2 +0,0 @@
1
- # active_record_6.0_ruby_2/join_association
2
- require 'polyamorous/activerecord_5.2_ruby_2/join_association'
@@ -1,2 +0,0 @@
1
- # active_record_6.0_ruby_2/reflection.rb
2
- require 'polyamorous/activerecord_5.2_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.2'
3
- end
@@ -1,27 +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.2.1'
22
-
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
- s.require_paths = ["lib"]
27
- 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