ransack 2.3.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.github/SECURITY.md +12 -0
- data/.github/workflows/codeql.yml +72 -0
- data/.github/workflows/cronjob.yml +99 -0
- data/.github/workflows/deploy.yml +35 -0
- data/.github/workflows/rubocop.yml +20 -0
- data/.github/workflows/test-deploy.yml +29 -0
- data/.github/workflows/test.yml +131 -0
- data/.nojekyll +0 -0
- data/.rubocop.yml +50 -0
- data/CHANGELOG.md +263 -1
- data/CONTRIBUTING.md +51 -29
- data/Gemfile +24 -10
- data/README.md +49 -917
- data/bug_report_templates/test-ransack-scope-and-column-same-name.rb +78 -0
- data/bug_report_templates/test-ransacker-arel-present-predicate.rb +75 -0
- 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 +288 -0
- data/docs/docs/getting-started/sorting.md +71 -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/img/create_release.png +0 -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 +46 -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 +42 -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 +8879 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +70 -0
- data/{polyamorous/lib/polyamorous/activerecord_6.0_ruby_2 → lib/polyamorous/activerecord_6.1_ruby_2}/join_dependency.rb +33 -12
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -0
- data/lib/polyamorous/activerecord_7.0_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_7.0_ruby_2/join_dependency.rb +1 -0
- data/lib/polyamorous/activerecord_7.0_ruby_2/reflection.rb +1 -0
- 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/{polyamorous/lib → lib/polyamorous}/polyamorous.rb +3 -8
- data/lib/ransack/adapters/active_record/base.rb +83 -10
- data/lib/ransack/adapters/active_record/context.rb +61 -116
- data/lib/ransack/configuration.rb +53 -10
- data/lib/ransack/constants.rb +126 -7
- data/lib/ransack/context.rb +34 -5
- data/lib/ransack/helpers/form_builder.rb +11 -17
- data/lib/ransack/helpers/form_helper.rb +14 -5
- data/lib/ransack/helpers.rb +1 -1
- data/lib/ransack/locale/sk.yml +70 -0
- data/lib/ransack/locale/sv.yml +70 -0
- data/lib/ransack/nodes/attribute.rb +3 -3
- data/lib/ransack/nodes/condition.rb +87 -8
- data/lib/ransack/nodes/grouping.rb +4 -4
- data/lib/ransack/nodes/node.rb +1 -1
- data/lib/ransack/nodes/sort.rb +3 -3
- data/lib/ransack/nodes/value.rb +3 -3
- data/lib/ransack/predicate.rb +3 -2
- data/lib/ransack/ransacker.rb +1 -1
- data/lib/ransack/search.rb +15 -7
- data/lib/ransack/translate.rb +6 -6
- data/lib/ransack/version.rb +1 -1
- data/lib/ransack/visitor.rb +38 -2
- data/lib/ransack.rb +6 -10
- data/ransack.gemspec +9 -24
- data/spec/blueprints/articles.rb +1 -1
- data/spec/blueprints/comments.rb +1 -1
- data/spec/blueprints/notes.rb +1 -1
- data/spec/blueprints/tags.rb +1 -1
- data/spec/console.rb +5 -5
- data/spec/helpers/polyamorous_helper.rb +2 -17
- data/spec/helpers/ransack_helper.rb +1 -1
- data/spec/polyamorous/activerecord_compatibility_spec.rb +15 -0
- data/spec/{ransack → polyamorous}/join_association_spec.rb +3 -1
- data/spec/{ransack → polyamorous}/join_dependency_spec.rb +0 -16
- data/spec/ransack/adapters/active_record/base_spec.rb +125 -16
- data/spec/ransack/adapters/active_record/context_spec.rb +19 -18
- data/spec/ransack/configuration_spec.rb +33 -9
- data/spec/ransack/helpers/form_builder_spec.rb +8 -8
- data/spec/ransack/helpers/form_helper_spec.rb +109 -20
- data/spec/ransack/nodes/condition_spec.rb +37 -0
- data/spec/ransack/nodes/grouping_spec.rb +2 -2
- data/spec/ransack/nodes/value_spec.rb +115 -0
- data/spec/ransack/predicate_spec.rb +75 -2
- data/spec/ransack/search_spec.rb +239 -38
- data/spec/ransack/translate_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -5
- data/spec/support/schema.rb +111 -12
- metadata +105 -195
- data/.travis.yml +0 -49
- data/lib/ransack/adapters/active_record/ransack/constants.rb +0 -116
- data/lib/ransack/adapters/active_record/ransack/context.rb +0 -60
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +0 -61
- data/lib/ransack/adapters/active_record/ransack/translate.rb +0 -8
- data/lib/ransack/adapters/active_record/ransack/visitor.rb +0 -47
- data/lib/ransack/adapters.rb +0 -64
- data/lib/ransack/nodes.rb +0 -8
- data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +0 -31
- data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +0 -112
- data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +0 -31
- data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +0 -112
- data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb +0 -12
- data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb +0 -22
- data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb +0 -81
- data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -2
- data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +0 -2
- data/polyamorous/lib/polyamorous/version.rb +0 -3
- data/polyamorous/polyamorous.gemspec +0 -35
- /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/{polyamorous/lib → lib}/polyamorous/join.rb +0 -0
- /data/{polyamorous/lib → lib}/polyamorous/swapping_reflection_class.rb +0 -0
- /data/{polyamorous/lib → lib}/polyamorous/tree_node.rb +0 -0
- /data/lib/ransack/{adapters/active_record.rb → active_record.rb} +0 -0
- /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,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
|
File without changes
|
File without changes
|