ransack 1.8.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.travis.yml +26 -63
- data/CHANGELOG.md +187 -24
- data/CONTRIBUTING.md +9 -0
- data/Gemfile +5 -20
- data/README.md +163 -40
- data/Rakefile +1 -22
- data/lib/ransack/adapters/active_record/base.rb +11 -2
- data/lib/ransack/adapters/active_record/context.rb +178 -168
- data/lib/ransack/adapters/active_record/ransack/constants.rb +6 -3
- data/lib/ransack/adapters/active_record/ransack/context.rb +10 -16
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +3 -3
- data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -5
- data/lib/ransack/adapters/active_record/ransack/visitor.rb +23 -0
- data/lib/ransack/adapters/active_record.rb +0 -9
- data/lib/ransack/adapters.rb +2 -0
- data/lib/ransack/configuration.rb +30 -4
- data/lib/ransack/constants.rb +4 -1
- data/lib/ransack/context.rb +29 -24
- data/lib/ransack/helpers/form_builder.rb +15 -3
- data/lib/ransack/helpers/form_helper.rb +8 -3
- data/lib/ransack/locale/ar.yml +70 -0
- data/lib/ransack/locale/az.yml +70 -0
- data/lib/ransack/locale/bg.yml +70 -0
- data/lib/ransack/locale/ca.yml +70 -0
- data/lib/ransack/locale/el.yml +70 -0
- data/lib/ransack/locale/es.yml +22 -22
- data/lib/ransack/locale/fa.yml +70 -0
- data/lib/ransack/locale/fi.yml +71 -0
- data/lib/ransack/locale/it.yml +70 -0
- data/lib/ransack/locale/nl.yml +4 -4
- data/lib/ransack/locale/ru.yml +70 -0
- data/lib/ransack/locale/tr.yml +70 -0
- data/lib/ransack/locale/zh-CN.yml +12 -12
- data/lib/ransack/nodes/attribute.rb +1 -1
- data/lib/ransack/nodes/grouping.rb +2 -7
- data/lib/ransack/nodes/value.rb +74 -68
- data/lib/ransack/predicate.rb +11 -19
- data/lib/ransack/search.rb +1 -1
- data/lib/ransack/translate.rb +115 -115
- data/lib/ransack/version.rb +1 -1
- data/lib/ransack/visitor.rb +1 -12
- data/lib/ransack.rb +5 -2
- data/logo/ransack-h.png +0 -0
- data/logo/ransack-h.svg +34 -0
- data/logo/ransack-v.png +0 -0
- data/logo/ransack-v.svg +34 -0
- data/logo/ransack.png +0 -0
- data/logo/ransack.svg +21 -0
- data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +31 -0
- data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +112 -0
- data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +31 -0
- data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +112 -0
- data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb +12 -0
- data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb +22 -0
- data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb +81 -0
- data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +81 -0
- data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +2 -0
- data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +2 -0
- data/polyamorous/lib/polyamorous/join.rb +70 -0
- data/polyamorous/lib/polyamorous/swapping_reflection_class.rb +11 -0
- data/polyamorous/lib/polyamorous/tree_node.rb +7 -0
- data/polyamorous/lib/polyamorous/version.rb +3 -0
- data/polyamorous/lib/polyamorous.rb +29 -0
- data/polyamorous/polyamorous.gemspec +35 -0
- data/ransack.gemspec +9 -10
- data/spec/helpers/polyamorous_helper.rb +28 -0
- data/spec/ransack/adapters/active_record/base_spec.rb +74 -0
- data/spec/ransack/adapters/active_record/context_spec.rb +44 -6
- data/spec/ransack/configuration_spec.rb +17 -2
- data/spec/ransack/helpers/form_builder_spec.rb +3 -15
- data/spec/ransack/helpers/form_helper_spec.rb +88 -151
- data/spec/ransack/join_association_spec.rb +28 -0
- data/spec/ransack/join_dependency_spec.rb +97 -0
- data/spec/ransack/join_spec.rb +19 -0
- data/spec/ransack/predicate_spec.rb +16 -2
- data/spec/ransack/search_spec.rb +32 -3
- data/spec/spec_helper.rb +5 -0
- data/spec/support/schema.rb +45 -21
- metadata +81 -67
- data/lib/ransack/adapters/active_record/3.0/compat.rb +0 -179
- data/lib/ransack/adapters/active_record/3.0/context.rb +0 -203
- data/lib/ransack/adapters/active_record/3.1/context.rb +0 -212
- data/lib/ransack/adapters/active_record/3.2/context.rb +0 -44
- data/lib/ransack/adapters/active_record/compat.rb +0 -14
- data/lib/ransack/adapters/mongoid/3.2/.gitkeep +0 -0
- data/lib/ransack/adapters/mongoid/attributes/attribute.rb +0 -37
- data/lib/ransack/adapters/mongoid/attributes/order_predications.rb +0 -17
- data/lib/ransack/adapters/mongoid/attributes/predications.rb +0 -141
- data/lib/ransack/adapters/mongoid/base.rb +0 -134
- data/lib/ransack/adapters/mongoid/context.rb +0 -212
- data/lib/ransack/adapters/mongoid/inquiry_hash.rb +0 -23
- data/lib/ransack/adapters/mongoid/ransack/constants.rb +0 -88
- data/lib/ransack/adapters/mongoid/ransack/context.rb +0 -60
- data/lib/ransack/adapters/mongoid/ransack/nodes/condition.rb +0 -27
- data/lib/ransack/adapters/mongoid/ransack/translate.rb +0 -13
- data/lib/ransack/adapters/mongoid/ransack/visitor.rb +0 -24
- data/lib/ransack/adapters/mongoid/table.rb +0 -35
- data/lib/ransack/adapters/mongoid.rb +0 -15
- data/spec/mongoid/adapters/mongoid/base_spec.rb +0 -314
- data/spec/mongoid/adapters/mongoid/context_spec.rb +0 -56
- data/spec/mongoid/configuration_spec.rb +0 -162
- data/spec/mongoid/dependencies_spec.rb +0 -8
- data/spec/mongoid/helpers/ransack_helper.rb +0 -11
- data/spec/mongoid/nodes/condition_spec.rb +0 -49
- data/spec/mongoid/nodes/grouping_spec.rb +0 -13
- data/spec/mongoid/predicate_spec.rb +0 -155
- data/spec/mongoid/search_spec.rb +0 -445
- data/spec/mongoid/support/mongoid.yml +0 -11
- data/spec/mongoid/support/schema.rb +0 -135
- data/spec/mongoid/translate_spec.rb +0 -14
- data/spec/mongoid_spec_helper.rb +0 -63
- data/spec/ransack/dependencies_spec.rb +0 -12
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Polyamorous
|
4
|
+
describe JoinDependency do
|
5
|
+
|
6
|
+
context 'with symbol joins' do
|
7
|
+
subject { new_join_dependency Person, articles: :comments }
|
8
|
+
|
9
|
+
specify { expect(subject.send(:join_root).drop(1).size)
|
10
|
+
.to eq(2) }
|
11
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
|
12
|
+
.to eq [Polyamorous::InnerJoin] }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with has_many :through association' do
|
16
|
+
subject { new_join_dependency Person, :authored_article_comments }
|
17
|
+
|
18
|
+
specify { expect(subject.send(:join_root).drop(1).size)
|
19
|
+
.to eq 1 }
|
20
|
+
specify { expect(subject.send(:join_root).drop(1).first.table_name)
|
21
|
+
.to eq 'comments' }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with outer join' do
|
25
|
+
subject { new_join_dependency Person, new_join(:articles, :outer) }
|
26
|
+
|
27
|
+
specify { expect(subject.send(:join_root).drop(1).size)
|
28
|
+
.to eq 1 }
|
29
|
+
specify { expect(subject.send(:join_root).drop(1).first.join_type)
|
30
|
+
.to eq Polyamorous::OuterJoin }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with nested outer joins' do
|
34
|
+
subject { new_join_dependency Person,
|
35
|
+
new_join(:articles, :outer) => new_join(:comments, :outer) }
|
36
|
+
|
37
|
+
specify { expect(subject.send(:join_root).drop(1).size)
|
38
|
+
.to eq 2 }
|
39
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
|
40
|
+
.to eq [Polyamorous::OuterJoin, Polyamorous::OuterJoin] }
|
41
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
|
42
|
+
.to eq [Polyamorous::OuterJoin] }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with polymorphic belongs_to join' do
|
46
|
+
subject { new_join_dependency Note, new_join(:notable, :inner, Person) }
|
47
|
+
|
48
|
+
specify { expect(subject.send(:join_root).drop(1).size)
|
49
|
+
.to eq 1 }
|
50
|
+
specify { expect(subject.send(:join_root).drop(1).first.join_type)
|
51
|
+
.to eq Polyamorous::InnerJoin }
|
52
|
+
specify { expect(subject.send(:join_root).drop(1).first.table_name)
|
53
|
+
.to eq 'people' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with polymorphic belongs_to join and nested symbol join' do
|
57
|
+
subject { new_join_dependency Note,
|
58
|
+
new_join(:notable, :inner, Person) => :comments }
|
59
|
+
|
60
|
+
specify { expect(subject.send(:join_root).drop(1).size)
|
61
|
+
.to eq 2 }
|
62
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
|
63
|
+
.to eq [Polyamorous::InnerJoin] }
|
64
|
+
specify { expect(subject.send(:join_root).drop(1).first.table_name)
|
65
|
+
.to eq 'people' }
|
66
|
+
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
|
67
|
+
.to eq 'comments' }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with polymorphic belongs_to join and nested join' do
|
71
|
+
subject { new_join_dependency Note,
|
72
|
+
new_join(:notable, :outer, Person) => :comments }
|
73
|
+
specify { expect(subject.send(:join_root).drop(1).size).to eq 2 }
|
74
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type)).to eq [Polyamorous::OuterJoin, Polyamorous::InnerJoin] }
|
75
|
+
specify { expect(subject.send(:join_root).drop(1).first.table_name)
|
76
|
+
.to eq 'people' }
|
77
|
+
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
|
78
|
+
.to eq 'comments' }
|
79
|
+
end
|
80
|
+
|
81
|
+
context '#left_outer_join in Rails 5 overrides join type specified',
|
82
|
+
if: ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MAJOR < 6 && ActiveRecord::VERSION::MINOR < 2 do
|
83
|
+
|
84
|
+
let(:join_type_class) do
|
85
|
+
new_join_dependency(
|
86
|
+
Person,
|
87
|
+
new_join(:articles)
|
88
|
+
).join_constraints(
|
89
|
+
[],
|
90
|
+
Arel::Nodes::OuterJoin
|
91
|
+
).first.joins.map(&:class)
|
92
|
+
end
|
93
|
+
|
94
|
+
specify { expect(join_type_class).to eq [Arel::Nodes::OuterJoin] }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Polyamorous
|
4
|
+
describe Join do
|
5
|
+
it 'is a tree node' do
|
6
|
+
join = new_join(:articles, :outer)
|
7
|
+
expect(join).to be_kind_of(TreeNode)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'can be added to a tree' do
|
11
|
+
join = new_join(:articles, :outer)
|
12
|
+
|
13
|
+
tree_hash = {}
|
14
|
+
join.add_to_tree(tree_hash)
|
15
|
+
|
16
|
+
expect(tree_hash[join]).to be {}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -126,7 +126,7 @@ module Ransack
|
|
126
126
|
(if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
|
127
127
|
/"people"."name" ILIKE '%\\%\\.\\_\\\\%'/
|
128
128
|
elsif ActiveRecord::Base.connection.adapter_name == "Mysql2"
|
129
|
-
/`people`.`name` LIKE '
|
129
|
+
/`people`.`name` LIKE '%\\\\%.\\\\_\\\\\\\\%'/
|
130
130
|
else
|
131
131
|
/"people"."name" LIKE '%%._\\%'/
|
132
132
|
end) do
|
@@ -145,7 +145,7 @@ module Ransack
|
|
145
145
|
(if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
|
146
146
|
/"people"."name" NOT ILIKE '%\\%\\.\\_\\\\%'/
|
147
147
|
elsif ActiveRecord::Base.connection.adapter_name == "Mysql2"
|
148
|
-
/`people`.`name` NOT LIKE '
|
148
|
+
/`people`.`name` NOT LIKE '%\\\\%.\\\\_\\\\\\\\%'/
|
149
149
|
else
|
150
150
|
/"people"."name" NOT LIKE '%%._\\%'/
|
151
151
|
end) do
|
@@ -381,6 +381,20 @@ module Ransack
|
|
381
381
|
end
|
382
382
|
end
|
383
383
|
|
384
|
+
context "defining custom predicates" do
|
385
|
+
describe "with 'not_in' arel predicate" do
|
386
|
+
before do
|
387
|
+
Ransack.configure {|c| c.add_predicate "not_in_csv", arel_predicate: "not_in", formatter: proc { |v| v.split(",") } }
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'generates a value IS NOT NULL query' do
|
391
|
+
@s.name_not_in_csv = ["a", "b"]
|
392
|
+
field = "#{quote_table_name("people")}.#{quote_column_name("name")}"
|
393
|
+
expect(@s.result.to_sql).to match /#{field} NOT IN \('a', 'b'\)/
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
384
398
|
private
|
385
399
|
|
386
400
|
def test_boolean_equality_for(boolean_value)
|
data/spec/ransack/search_spec.rb
CHANGED
@@ -227,13 +227,37 @@ module Ransack
|
|
227
227
|
children_people_name_field} = 'Ernie'/
|
228
228
|
end
|
229
229
|
|
230
|
+
it 'use appropriate table alias' do
|
231
|
+
skip "Make this spec pass for Rails <5.2" if ::ActiveRecord::VERSION::STRING < '5.2.0'
|
232
|
+
s = Search.new(Person, {
|
233
|
+
name_eq: "person_name_query",
|
234
|
+
articles_title_eq: "person_article_title_query",
|
235
|
+
parent_name_eq: "parent_name_query",
|
236
|
+
parent_articles_title_eq: 'parents_article_title_query'
|
237
|
+
}).result
|
238
|
+
real_query = remove_quotes_and_backticks(s.to_sql)
|
239
|
+
|
240
|
+
expect(real_query)
|
241
|
+
.to match(%r{LEFT OUTER JOIN articles ON (\('default_scope' = 'default_scope'\) AND )?articles.person_id = people.id})
|
242
|
+
expect(real_query)
|
243
|
+
.to match(%r{LEFT OUTER JOIN articles articles_people ON (\('default_scope' = 'default_scope'\) AND )?articles_people.person_id = parents_people.id})
|
244
|
+
expect(real_query)
|
245
|
+
.to include "people.name = 'person_name_query'"
|
246
|
+
expect(real_query)
|
247
|
+
.to include "articles.title = 'person_article_title_query'"
|
248
|
+
expect(real_query)
|
249
|
+
.to include "parents_people.name = 'parent_name_query'"
|
250
|
+
expect(real_query)
|
251
|
+
.to include "articles_people.title = 'parents_article_title_query'"
|
252
|
+
end
|
253
|
+
|
230
254
|
# FIXME: Make this spec pass for Rails 4.1 / 4.2 / 5.0 and not just 4.0 by
|
231
255
|
# commenting out lines 221 and 242 to run the test. Addresses issue #374.
|
232
256
|
# https://github.com/activerecord-hackery/ransack/issues/374
|
233
257
|
#
|
234
258
|
it 'evaluates conditions for multiple `belongs_to` associations to the
|
235
|
-
same table contextually'
|
236
|
-
|
259
|
+
same table contextually' do
|
260
|
+
skip "Make this spec pass for Rails <5.2" if ::ActiveRecord::VERSION::STRING < '5.2.0'
|
237
261
|
s = Search.new(
|
238
262
|
Recommendation,
|
239
263
|
person_name_eq: 'Ernie',
|
@@ -248,7 +272,7 @@ module Ransack
|
|
248
272
|
ON target_people_recommendations.id = recommendations.target_person_id
|
249
273
|
LEFT OUTER JOIN people parents_people
|
250
274
|
ON parents_people.id = target_people_recommendations.parent_id
|
251
|
-
WHERE (
|
275
|
+
WHERE (people.name = 'Ernie' AND parents_people.name = 'Test')
|
252
276
|
SQL
|
253
277
|
.squish
|
254
278
|
expect(real_query).to eq expected_query
|
@@ -316,6 +340,11 @@ module Ransack
|
|
316
340
|
.to eq s.result(distinct: true).send(all_or_load)
|
317
341
|
end
|
318
342
|
|
343
|
+
it 'evaluates joins with belongs_to join' do
|
344
|
+
s = Person.joins(:parent).ransack(parent_name_eq: 'Ernie').result(distinct: true)
|
345
|
+
expect(s).to be_an ActiveRecord::Relation
|
346
|
+
end
|
347
|
+
|
319
348
|
private
|
320
349
|
|
321
350
|
def remove_quotes_and_backticks(str)
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,10 @@ require 'sham'
|
|
3
3
|
require 'faker'
|
4
4
|
require 'ransack'
|
5
5
|
require 'pry'
|
6
|
+
require 'simplecov'
|
7
|
+
require 'byebug'
|
6
8
|
|
9
|
+
SimpleCov.start
|
7
10
|
I18n.enforce_available_locales = false
|
8
11
|
Time.zone = 'Eastern Time (US & Canada)'
|
9
12
|
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'support', '*.yml')]
|
@@ -35,12 +38,14 @@ RSpec.configure do |config|
|
|
35
38
|
line = '=' * message.length
|
36
39
|
puts line, message, line
|
37
40
|
Schema.create
|
41
|
+
SubDB::Schema.create
|
38
42
|
end
|
39
43
|
|
40
44
|
config.before(:all) { Sham.reset(:before_all) }
|
41
45
|
config.before(:each) { Sham.reset(:before_each) }
|
42
46
|
|
43
47
|
config.include RansackHelper
|
48
|
+
config.include PolyamorousHelper
|
44
49
|
end
|
45
50
|
|
46
51
|
RSpec::Matchers.define :be_like do |expected|
|
data/spec/support/schema.rb
CHANGED
@@ -25,26 +25,14 @@ else
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class Person < ActiveRecord::Base
|
28
|
-
|
29
|
-
default_scope order('id DESC')
|
30
|
-
else
|
31
|
-
default_scope { order(id: :desc) }
|
32
|
-
end
|
28
|
+
default_scope { order(id: :desc) }
|
33
29
|
belongs_to :parent, class_name: 'Person', foreign_key: :parent_id
|
34
30
|
has_many :children, class_name: 'Person', foreign_key: :parent_id
|
35
31
|
has_many :articles
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
conditions: "published = 't'"
|
40
|
-
else
|
41
|
-
has_many :published_articles, class_name: "Article",
|
42
|
-
conditions: { published: true }
|
43
|
-
end
|
44
|
-
else
|
45
|
-
has_many :published_articles, ->{ where(published: true) },
|
32
|
+
has_many :story_articles
|
33
|
+
|
34
|
+
has_many :published_articles, ->{ where(published: true) },
|
46
35
|
class_name: "Article"
|
47
|
-
end
|
48
36
|
has_many :comments
|
49
37
|
has_many :authored_article_comments, through: :articles,
|
50
38
|
source: :comments, foreign_key: :person_id
|
@@ -57,6 +45,9 @@ class Person < ActiveRecord::Base
|
|
57
45
|
of_age ? where("age >= ?", 18) : where("age < ?", 18)
|
58
46
|
}
|
59
47
|
|
48
|
+
scope :sort_by_reverse_name_asc, lambda { order(Arel.sql("REVERSE(name) ASC")) }
|
49
|
+
scope :sort_by_reverse_name_desc, lambda { order("REVERSE(name) DESC") }
|
50
|
+
|
60
51
|
alias_attribute :full_name, :name
|
61
52
|
|
62
53
|
ransack_alias :term, :name_or_email
|
@@ -92,10 +83,15 @@ class Person < ActiveRecord::Base
|
|
92
83
|
)
|
93
84
|
end
|
94
85
|
|
86
|
+
|
95
87
|
ransacker :sql_literal_id do
|
96
88
|
Arel.sql('people.id')
|
97
89
|
end
|
98
90
|
|
91
|
+
ransacker :name_case_insensitive, type: :string do
|
92
|
+
arel_table[:name].lower
|
93
|
+
end
|
94
|
+
|
99
95
|
ransacker :with_arguments, args: [:parent, :ransacker_args] do |parent, args|
|
100
96
|
min, max = args
|
101
97
|
query = <<-SQL
|
@@ -110,6 +106,7 @@ class Person < ActiveRecord::Base
|
|
110
106
|
Arel.sql(query)
|
111
107
|
end
|
112
108
|
|
109
|
+
|
113
110
|
def self.ransackable_attributes(auth_object = nil)
|
114
111
|
if auth_object == :admin
|
115
112
|
super - ['only_sort']
|
@@ -138,11 +135,10 @@ class Article < ActiveRecord::Base
|
|
138
135
|
|
139
136
|
alias_attribute :content, :body
|
140
137
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
138
|
+
default_scope { where("'default_scope' = 'default_scope'") }
|
139
|
+
end
|
140
|
+
|
141
|
+
class StoryArticle < Article
|
146
142
|
end
|
147
143
|
|
148
144
|
class Recommendation < ActiveRecord::Base
|
@@ -203,6 +199,7 @@ module Schema
|
|
203
199
|
t.string :title
|
204
200
|
t.text :subject_header
|
205
201
|
t.text :body
|
202
|
+
t.string :type
|
206
203
|
t.boolean :published, default: true
|
207
204
|
end
|
208
205
|
|
@@ -255,3 +252,30 @@ module Schema
|
|
255
252
|
)
|
256
253
|
end
|
257
254
|
end
|
255
|
+
|
256
|
+
module SubDB
|
257
|
+
class Base < ActiveRecord::Base
|
258
|
+
self.abstract_class = true
|
259
|
+
establish_connection(
|
260
|
+
adapter: 'sqlite3',
|
261
|
+
database: ':memory:'
|
262
|
+
)
|
263
|
+
end
|
264
|
+
|
265
|
+
class OperationHistory < Base
|
266
|
+
end
|
267
|
+
|
268
|
+
module Schema
|
269
|
+
def self.create
|
270
|
+
s = ::ActiveRecord::Schema.new
|
271
|
+
s.instance_variable_set(:@connection, SubDB::Base.connection)
|
272
|
+
s.verbose = false
|
273
|
+
s.define({}) do
|
274
|
+
create_table :operation_histories, force: true do |t|
|
275
|
+
t.string :operation_type
|
276
|
+
t.integer :people_id
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Miller
|
8
8
|
- Ryan Bigg
|
9
9
|
- Jon Atack
|
10
|
+
- Sean Carroll
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2019-08-18 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: actionpack
|
@@ -18,42 +19,42 @@ dependencies:
|
|
18
19
|
requirements:
|
19
20
|
- - ">="
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
+
version: '5.0'
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
29
|
+
version: '5.0'
|
29
30
|
- !ruby/object:Gem::Dependency
|
30
31
|
name: activerecord
|
31
32
|
requirement: !ruby/object:Gem::Requirement
|
32
33
|
requirements:
|
33
34
|
- - ">="
|
34
35
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
36
|
+
version: '5.0'
|
36
37
|
type: :runtime
|
37
38
|
prerelease: false
|
38
39
|
version_requirements: !ruby/object:Gem::Requirement
|
39
40
|
requirements:
|
40
41
|
- - ">="
|
41
42
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
43
|
+
version: '5.0'
|
43
44
|
- !ruby/object:Gem::Dependency
|
44
45
|
name: activesupport
|
45
46
|
requirement: !ruby/object:Gem::Requirement
|
46
47
|
requirements:
|
47
48
|
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
50
|
+
version: '5.0'
|
50
51
|
type: :runtime
|
51
52
|
prerelease: false
|
52
53
|
version_requirements: !ruby/object:Gem::Requirement
|
53
54
|
requirements:
|
54
55
|
- - ">="
|
55
56
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
57
|
+
version: '5.0'
|
57
58
|
- !ruby/object:Gem::Dependency
|
58
59
|
name: i18n
|
59
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,16 +73,16 @@ dependencies:
|
|
72
73
|
name: polyamorous
|
73
74
|
requirement: !ruby/object:Gem::Requirement
|
74
75
|
requirements:
|
75
|
-
- -
|
76
|
+
- - '='
|
76
77
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
+
version: 2.3.0
|
78
79
|
type: :runtime
|
79
80
|
prerelease: false
|
80
81
|
version_requirements: !ruby/object:Gem::Requirement
|
81
82
|
requirements:
|
82
|
-
- -
|
83
|
+
- - '='
|
83
84
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
85
|
+
version: 2.3.0
|
85
86
|
- !ruby/object:Gem::Dependency
|
86
87
|
name: rspec
|
87
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,28 +131,28 @@ dependencies:
|
|
130
131
|
requirements:
|
131
132
|
- - "~>"
|
132
133
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.
|
134
|
+
version: 1.4.1
|
134
135
|
type: :development
|
135
136
|
prerelease: false
|
136
137
|
version_requirements: !ruby/object:Gem::Requirement
|
137
138
|
requirements:
|
138
139
|
- - "~>"
|
139
140
|
- !ruby/object:Gem::Version
|
140
|
-
version: 1.
|
141
|
+
version: 1.4.1
|
141
142
|
- !ruby/object:Gem::Dependency
|
142
143
|
name: pg
|
143
144
|
requirement: !ruby/object:Gem::Requirement
|
144
145
|
requirements:
|
145
|
-
- - "
|
146
|
+
- - "~>"
|
146
147
|
- !ruby/object:Gem::Version
|
147
|
-
version: '0'
|
148
|
+
version: '0.21'
|
148
149
|
type: :development
|
149
150
|
prerelease: false
|
150
151
|
version_requirements: !ruby/object:Gem::Requirement
|
151
152
|
requirements:
|
152
|
-
- - "
|
153
|
+
- - "~>"
|
153
154
|
- !ruby/object:Gem::Version
|
154
|
-
version: '0'
|
155
|
+
version: '0.21'
|
155
156
|
- !ruby/object:Gem::Dependency
|
156
157
|
name: mysql2
|
157
158
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,12 +181,27 @@ dependencies:
|
|
180
181
|
- - '='
|
181
182
|
- !ruby/object:Gem::Version
|
182
183
|
version: '0.10'
|
184
|
+
- !ruby/object:Gem::Dependency
|
185
|
+
name: byebug
|
186
|
+
requirement: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
type: :development
|
192
|
+
prerelease: false
|
193
|
+
version_requirements: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
183
198
|
description: Ransack is the successor to the MetaSearch gem. It improves and expands
|
184
199
|
upon MetaSearch's functionality, but does not have a 100%-compatible API.
|
185
200
|
email:
|
186
201
|
- ernie@erniemiller.org
|
187
202
|
- radarlistener@gmail.com
|
188
203
|
- jonnyatack@gmail.com
|
204
|
+
- sfcarroll@gmail.com
|
189
205
|
executables: []
|
190
206
|
extensions: []
|
191
207
|
extra_rdoc_files: []
|
@@ -201,50 +217,41 @@ files:
|
|
201
217
|
- lib/ransack.rb
|
202
218
|
- lib/ransack/adapters.rb
|
203
219
|
- lib/ransack/adapters/active_record.rb
|
204
|
-
- lib/ransack/adapters/active_record/3.0/compat.rb
|
205
|
-
- lib/ransack/adapters/active_record/3.0/context.rb
|
206
|
-
- lib/ransack/adapters/active_record/3.1/context.rb
|
207
|
-
- lib/ransack/adapters/active_record/3.2/context.rb
|
208
220
|
- lib/ransack/adapters/active_record/base.rb
|
209
|
-
- lib/ransack/adapters/active_record/compat.rb
|
210
221
|
- lib/ransack/adapters/active_record/context.rb
|
211
222
|
- lib/ransack/adapters/active_record/ransack/constants.rb
|
212
223
|
- lib/ransack/adapters/active_record/ransack/context.rb
|
213
224
|
- lib/ransack/adapters/active_record/ransack/nodes/condition.rb
|
214
225
|
- lib/ransack/adapters/active_record/ransack/translate.rb
|
215
226
|
- lib/ransack/adapters/active_record/ransack/visitor.rb
|
216
|
-
- lib/ransack/adapters/mongoid.rb
|
217
|
-
- lib/ransack/adapters/mongoid/3.2/.gitkeep
|
218
|
-
- lib/ransack/adapters/mongoid/attributes/attribute.rb
|
219
|
-
- lib/ransack/adapters/mongoid/attributes/order_predications.rb
|
220
|
-
- lib/ransack/adapters/mongoid/attributes/predications.rb
|
221
|
-
- lib/ransack/adapters/mongoid/base.rb
|
222
|
-
- lib/ransack/adapters/mongoid/context.rb
|
223
|
-
- lib/ransack/adapters/mongoid/inquiry_hash.rb
|
224
|
-
- lib/ransack/adapters/mongoid/ransack/constants.rb
|
225
|
-
- lib/ransack/adapters/mongoid/ransack/context.rb
|
226
|
-
- lib/ransack/adapters/mongoid/ransack/nodes/condition.rb
|
227
|
-
- lib/ransack/adapters/mongoid/ransack/translate.rb
|
228
|
-
- lib/ransack/adapters/mongoid/ransack/visitor.rb
|
229
|
-
- lib/ransack/adapters/mongoid/table.rb
|
230
227
|
- lib/ransack/configuration.rb
|
231
228
|
- lib/ransack/constants.rb
|
232
229
|
- lib/ransack/context.rb
|
233
230
|
- lib/ransack/helpers.rb
|
234
231
|
- lib/ransack/helpers/form_builder.rb
|
235
232
|
- lib/ransack/helpers/form_helper.rb
|
233
|
+
- lib/ransack/locale/ar.yml
|
234
|
+
- lib/ransack/locale/az.yml
|
235
|
+
- lib/ransack/locale/bg.yml
|
236
|
+
- lib/ransack/locale/ca.yml
|
236
237
|
- lib/ransack/locale/cs.yml
|
237
238
|
- lib/ransack/locale/da.yml
|
238
239
|
- lib/ransack/locale/de.yml
|
240
|
+
- lib/ransack/locale/el.yml
|
239
241
|
- lib/ransack/locale/en.yml
|
240
242
|
- lib/ransack/locale/es.yml
|
243
|
+
- lib/ransack/locale/fa.yml
|
244
|
+
- lib/ransack/locale/fi.yml
|
241
245
|
- lib/ransack/locale/fr.yml
|
242
246
|
- lib/ransack/locale/hu.yml
|
243
247
|
- lib/ransack/locale/id.yml
|
248
|
+
- lib/ransack/locale/it.yml
|
244
249
|
- lib/ransack/locale/ja.yml
|
245
250
|
- lib/ransack/locale/nl.yml
|
246
251
|
- lib/ransack/locale/pt-BR.yml
|
247
252
|
- lib/ransack/locale/ro.yml
|
253
|
+
- lib/ransack/locale/ru.yml
|
254
|
+
- lib/ransack/locale/tr.yml
|
248
255
|
- lib/ransack/locale/zh-CN.yml
|
249
256
|
- lib/ransack/locale/zh-TW.yml
|
250
257
|
- lib/ransack/naming.rb
|
@@ -262,6 +269,34 @@ files:
|
|
262
269
|
- lib/ransack/translate.rb
|
263
270
|
- lib/ransack/version.rb
|
264
271
|
- lib/ransack/visitor.rb
|
272
|
+
- logo/ransack-h.png
|
273
|
+
- logo/ransack-h.svg
|
274
|
+
- logo/ransack-v.png
|
275
|
+
- logo/ransack-v.svg
|
276
|
+
- logo/ransack.png
|
277
|
+
- logo/ransack.svg
|
278
|
+
- polyamorous/lib/polyamorous.rb
|
279
|
+
- polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb
|
280
|
+
- polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb
|
281
|
+
- polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb
|
282
|
+
- polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb
|
283
|
+
- polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb
|
284
|
+
- polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb
|
285
|
+
- polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb
|
286
|
+
- polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb
|
287
|
+
- polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb
|
288
|
+
- polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb
|
289
|
+
- polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb
|
290
|
+
- polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb
|
291
|
+
- polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb
|
292
|
+
- polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb
|
293
|
+
- polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb
|
294
|
+
- polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb
|
295
|
+
- polyamorous/lib/polyamorous/join.rb
|
296
|
+
- polyamorous/lib/polyamorous/swapping_reflection_class.rb
|
297
|
+
- polyamorous/lib/polyamorous/tree_node.rb
|
298
|
+
- polyamorous/lib/polyamorous/version.rb
|
299
|
+
- polyamorous/polyamorous.gemspec
|
265
300
|
- ransack.gemspec
|
266
301
|
- spec/blueprints/articles.rb
|
267
302
|
- spec/blueprints/comments.rb
|
@@ -269,26 +304,16 @@ files:
|
|
269
304
|
- spec/blueprints/people.rb
|
270
305
|
- spec/blueprints/tags.rb
|
271
306
|
- spec/console.rb
|
307
|
+
- spec/helpers/polyamorous_helper.rb
|
272
308
|
- spec/helpers/ransack_helper.rb
|
273
|
-
- spec/mongoid/adapters/mongoid/base_spec.rb
|
274
|
-
- spec/mongoid/adapters/mongoid/context_spec.rb
|
275
|
-
- spec/mongoid/configuration_spec.rb
|
276
|
-
- spec/mongoid/dependencies_spec.rb
|
277
|
-
- spec/mongoid/helpers/ransack_helper.rb
|
278
|
-
- spec/mongoid/nodes/condition_spec.rb
|
279
|
-
- spec/mongoid/nodes/grouping_spec.rb
|
280
|
-
- spec/mongoid/predicate_spec.rb
|
281
|
-
- spec/mongoid/search_spec.rb
|
282
|
-
- spec/mongoid/support/mongoid.yml
|
283
|
-
- spec/mongoid/support/schema.rb
|
284
|
-
- spec/mongoid/translate_spec.rb
|
285
|
-
- spec/mongoid_spec_helper.rb
|
286
309
|
- spec/ransack/adapters/active_record/base_spec.rb
|
287
310
|
- spec/ransack/adapters/active_record/context_spec.rb
|
288
311
|
- spec/ransack/configuration_spec.rb
|
289
|
-
- spec/ransack/dependencies_spec.rb
|
290
312
|
- spec/ransack/helpers/form_builder_spec.rb
|
291
313
|
- spec/ransack/helpers/form_helper_spec.rb
|
314
|
+
- spec/ransack/join_association_spec.rb
|
315
|
+
- spec/ransack/join_dependency_spec.rb
|
316
|
+
- spec/ransack/join_spec.rb
|
292
317
|
- spec/ransack/nodes/condition_spec.rb
|
293
318
|
- spec/ransack/nodes/grouping_spec.rb
|
294
319
|
- spec/ransack/predicate_spec.rb
|
@@ -316,8 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
341
|
- !ruby/object:Gem::Version
|
317
342
|
version: '0'
|
318
343
|
requirements: []
|
319
|
-
|
320
|
-
rubygems_version: 2.5.2
|
344
|
+
rubygems_version: 3.0.2
|
321
345
|
signing_key:
|
322
346
|
specification_version: 4
|
323
347
|
summary: Object-based searching for Active Record and Mongoid (currently).
|
@@ -328,26 +352,16 @@ test_files:
|
|
328
352
|
- spec/blueprints/people.rb
|
329
353
|
- spec/blueprints/tags.rb
|
330
354
|
- spec/console.rb
|
355
|
+
- spec/helpers/polyamorous_helper.rb
|
331
356
|
- spec/helpers/ransack_helper.rb
|
332
|
-
- spec/mongoid/adapters/mongoid/base_spec.rb
|
333
|
-
- spec/mongoid/adapters/mongoid/context_spec.rb
|
334
|
-
- spec/mongoid/configuration_spec.rb
|
335
|
-
- spec/mongoid/dependencies_spec.rb
|
336
|
-
- spec/mongoid/helpers/ransack_helper.rb
|
337
|
-
- spec/mongoid/nodes/condition_spec.rb
|
338
|
-
- spec/mongoid/nodes/grouping_spec.rb
|
339
|
-
- spec/mongoid/predicate_spec.rb
|
340
|
-
- spec/mongoid/search_spec.rb
|
341
|
-
- spec/mongoid/support/mongoid.yml
|
342
|
-
- spec/mongoid/support/schema.rb
|
343
|
-
- spec/mongoid/translate_spec.rb
|
344
|
-
- spec/mongoid_spec_helper.rb
|
345
357
|
- spec/ransack/adapters/active_record/base_spec.rb
|
346
358
|
- spec/ransack/adapters/active_record/context_spec.rb
|
347
359
|
- spec/ransack/configuration_spec.rb
|
348
|
-
- spec/ransack/dependencies_spec.rb
|
349
360
|
- spec/ransack/helpers/form_builder_spec.rb
|
350
361
|
- spec/ransack/helpers/form_helper_spec.rb
|
362
|
+
- spec/ransack/join_association_spec.rb
|
363
|
+
- spec/ransack/join_dependency_spec.rb
|
364
|
+
- spec/ransack/join_spec.rb
|
351
365
|
- spec/ransack/nodes/condition_spec.rb
|
352
366
|
- spec/ransack/nodes/grouping_spec.rb
|
353
367
|
- spec/ransack/predicate_spec.rb
|