ransack 2.1.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +32 -22
- data/CHANGELOG.md +60 -1
- data/CONTRIBUTING.md +11 -6
- data/Gemfile +21 -17
- data/README.md +56 -29
- data/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_association.rb +2 -9
- data/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_dependency.rb +25 -3
- data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +11 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +80 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +74 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +93 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +1 -0
- data/lib/{polyamorous.rb → polyamorous/polyamorous.rb} +3 -3
- data/lib/ransack.rb +2 -2
- data/lib/ransack/adapters/active_record/base.rb +1 -0
- data/lib/ransack/adapters/active_record/context.rb +60 -68
- data/lib/ransack/adapters/active_record/ransack/constants.rb +17 -2
- data/lib/ransack/adapters/active_record/ransack/context.rb +2 -6
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +12 -5
- data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -1
- data/lib/ransack/constants.rb +2 -3
- data/lib/ransack/context.rb +19 -18
- data/lib/ransack/helpers/form_builder.rb +5 -11
- data/lib/ransack/helpers/form_helper.rb +1 -1
- data/lib/ransack/locale/ar.yml +70 -0
- data/lib/ransack/locale/az.yml +1 -1
- data/lib/ransack/locale/ca.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/sk.yml +70 -0
- data/lib/ransack/locale/zh-CN.yml +12 -12
- data/lib/ransack/nodes/condition.rb +8 -0
- data/lib/ransack/nodes/grouping.rb +1 -1
- data/lib/ransack/predicate.rb +2 -1
- data/lib/ransack/search.rb +1 -0
- data/lib/ransack/translate.rb +115 -115
- data/lib/ransack/version.rb +1 -1
- data/ransack.gemspec +5 -21
- data/spec/helpers/polyamorous_helper.rb +3 -8
- data/spec/{ransack → polyamorous}/join_association_spec.rb +7 -0
- data/spec/{ransack → polyamorous}/join_dependency_spec.rb +18 -7
- data/spec/{ransack → polyamorous}/join_spec.rb +0 -0
- data/spec/ransack/adapters/active_record/base_spec.rb +8 -8
- data/spec/ransack/adapters/active_record/context_spec.rb +60 -17
- data/spec/ransack/helpers/form_helper_spec.rb +51 -51
- data/spec/ransack/predicate_spec.rb +54 -2
- data/spec/ransack/search_spec.rb +78 -13
- data/spec/spec_helper.rb +4 -0
- data/spec/support/schema.rb +13 -2
- metadata +29 -136
- data/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +0 -2
- data/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +0 -2
- data/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +0 -32
- data/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +0 -112
- data/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +0 -32
- data/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +0 -113
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5cd517575121b1f2c1041501645a95680a4efbe82c0b2d6c74e079d080cda29
|
4
|
+
data.tar.gz: f927c47bfc28f15d7a24eb2761ae1d003ff18912c1c91e7716ed2628f9012ccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be9485ce5f692f990c7b8c5b59c961311783fafb845c3580dbd0d08eb62e24c1067da75e98f24cd4553e7db21a15531ca2943c1633566995a6e7c64d6310d2f2
|
7
|
+
data.tar.gz: 3fbca263c9e5f399695e9cc69e50762fc72875860ad495c04368ff84d90c68100d5ca1b6db22aa17a5c2c52efccd4d99bc0c29b5485ae6608390a606fd35ac18
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,37 +1,47 @@
|
|
1
|
-
|
1
|
+
branches: master
|
2
2
|
|
3
|
-
|
3
|
+
language: ruby
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
- 2.
|
6
|
+
- 2.6.6
|
7
|
+
|
8
|
+
services:
|
9
|
+
- mysql
|
7
10
|
|
8
11
|
env:
|
12
|
+
- RAILS=v6.1.0.rc1 DB=sqlite3
|
13
|
+
- RAILS=v6.1.0.rc1 DB=mysql
|
14
|
+
- RAILS=v6.1.0.rc1 DB=postgres
|
15
|
+
|
16
|
+
- RAILS=v6.0.3 DB=sqlite3
|
17
|
+
- RAILS=v6.0.3 DB=mysql
|
18
|
+
- RAILS=v6.0.3 DB=postgres
|
19
|
+
|
20
|
+
- RAILS=6-0-stable DB=sqlite3
|
21
|
+
- RAILS=6-0-stable DB=mysql
|
22
|
+
- RAILS=6-0-stable DB=postgres
|
23
|
+
|
9
24
|
- RAILS=5-2-stable DB=sqlite3
|
10
25
|
- RAILS=5-2-stable DB=mysql
|
11
26
|
- RAILS=5-2-stable DB=postgres
|
12
27
|
|
13
|
-
- RAILS=v5.2.
|
14
|
-
- RAILS=v5.2.
|
15
|
-
- RAILS=v5.2.
|
16
|
-
|
17
|
-
- RAILS=v5.2.0 DB=sqlite3
|
18
|
-
- RAILS=v5.2.0 DB=mysql
|
19
|
-
- RAILS=v5.2.0 DB=postgres
|
28
|
+
- RAILS=v5.2.4 DB=sqlite3
|
29
|
+
- RAILS=v5.2.4 DB=mysql
|
30
|
+
- RAILS=v5.2.4 DB=postgres
|
20
31
|
|
21
|
-
- RAILS=5-1-stable DB=sqlite3
|
22
|
-
- RAILS=5-1-stable DB=mysql
|
23
|
-
- RAILS=5-1-stable DB=postgres
|
24
|
-
|
25
|
-
matrix:
|
26
|
-
allow_failures:
|
27
|
-
- env: RAILS=5-2-stable DB=sqlite3
|
28
|
-
- env: RAILS=5-2-stable DB=mysql
|
29
|
-
- env: RAILS=5-2-stable DB=postgres
|
30
32
|
before_script:
|
31
|
-
-
|
32
|
-
|
33
|
-
|
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
|
34
43
|
|
35
44
|
addons:
|
36
45
|
code_climate:
|
37
46
|
repo_token: 8b701c4364d51a0217105e08c06922d600cec3d9e60d546a89e3ddfe46e0664e
|
47
|
+
postgresql: "9.6"
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,65 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
##
|
3
|
+
## 2.4.0 - 2020-11-27
|
4
|
+
|
5
|
+
*
|
6
|
+
PR []()
|
7
|
+
|
8
|
+
* Support ActiveRecord 6.1.0.rc1.
|
9
|
+
PR [1172](https://github.com/activerecord-hackery/ransack/pull/1172)
|
10
|
+
|
11
|
+
* Fix for ActiveRecord 5.2.4 (note security fix in 5.2.4.2 for ActiveView's escape_javascript CVE-2020-5267 for all earlier versions)
|
12
|
+
|
13
|
+
* Drop support for ActiveRecord older than 5.2.4.
|
14
|
+
PR [1166](https://github.com/activerecord-hackery/ransack/pull/1166)
|
15
|
+
|
16
|
+
## 2.3.2 - 2020-01-11
|
17
|
+
|
18
|
+
* Breakfix to bump Polyamorous
|
19
|
+
|
20
|
+
## 2.3.1 - 2020-01-11
|
21
|
+
|
22
|
+
* Drop support for Active Record 5.0, 5.1, and 5.2.0.
|
23
|
+
PR [#1073](https://github.com/activerecord-hackery/ransack/pull/1073)
|
24
|
+
|
25
|
+
* Drop support for rubies under 2.3.
|
26
|
+
PR [#1070](https://github.com/activerecord-hackery/ransack/pull/1070)
|
27
|
+
|
28
|
+
... and others
|
29
|
+
|
30
|
+
## 2.3.0 - 2019-08-18
|
31
|
+
|
32
|
+
* Arabic translations PR [979](https://github.com/activerecord-hackery/ransack/pull/979)
|
33
|
+
|
34
|
+
* Rails 6 PR [1027](https://github.com/activerecord-hackery/ransack/pull/1027)
|
35
|
+
*vrodokanakis*
|
36
|
+
|
37
|
+
* Make polyamorous a separate gem PR [1002](https://github.com/activerecord-hackery/ransack/pull/1002)
|
38
|
+
|
39
|
+
* Catalan translations PR[1007](https://github.com/activerecord-hackery/ransack/pull/1007)
|
40
|
+
*roslavych*
|
41
|
+
|
42
|
+
* Don't escape period characters with wildcard searches in mysql2 PR [1013](https://github.com/activerecord-hackery/ransack/pull/1013)
|
43
|
+
*daflip*
|
44
|
+
|
45
|
+
* Farsi translations PR [1030](https://github.com/activerecord-hackery/ransack/pull/1030)
|
46
|
+
|
47
|
+
* Finnish translations PR [1049](https://github.com/activerecord-hackery/ransack/pull/1049)
|
48
|
+
|
49
|
+
* Fix wrong table alias when using nested join. for ActiveRecord >= 5.2
|
50
|
+
PR [374](https://github.com/activerecord-hackery/ransack/pull/374)
|
51
|
+
|
52
|
+
*hiichan*
|
53
|
+
|
54
|
+
## Version 2.1.1 - 2018-12-05
|
55
|
+
|
56
|
+
* Add `arabic` translation
|
57
|
+
https://github.com/activerecord-hackery/ransack/pull/979
|
58
|
+
|
59
|
+
* Deprecate #search
|
60
|
+
PR [975](https://github.com/activerecord-hackery/ransack/pull/975)
|
61
|
+
|
62
|
+
## Version 2.1.0 - 2018-10-26
|
4
63
|
|
5
64
|
* Add support for sorting by scopes
|
6
65
|
PR [973](https://github.com/activerecord-hackery/ransack/pull/973)
|
data/CONTRIBUTING.md
CHANGED
@@ -64,6 +64,9 @@ Here's a quick guide:
|
|
64
64
|
2. Create a thoughtfully-named branch for your changes (`git checkout -b my-new-feature`).
|
65
65
|
|
66
66
|
3. Install the development dependencies by running `bundle install`.
|
67
|
+
To install rails other than latest (set in Gemfile): `RAILS='5-2-stable' bundle install`
|
68
|
+
|
69
|
+
$ RAILS='5-2-stable' bundle install
|
67
70
|
|
68
71
|
4. Begin by running the tests. We only take pull requests with passing tests,
|
69
72
|
and it's great to know that you have a clean slate:
|
@@ -84,16 +87,18 @@ Here's a quick guide:
|
|
84
87
|
$ mysql -u root
|
85
88
|
mysql> create database ransack;
|
86
89
|
|
87
|
-
|
90
|
+
The test suite runs by default
|
91
|
+
|
92
|
+
To run only the tests in a particular file: `bundle exec rspec <path/to/filename>`
|
88
93
|
|
89
|
-
$ rspec spec/ransack/search_spec.rb
|
94
|
+
$ bundle exec rspec spec/ransack/search_spec.rb
|
90
95
|
|
91
|
-
To run a single test in that file: `rspec <path/to/filename> -e "test name"`
|
96
|
+
To run a single test in that file: `bundle exec rspec <path/to/filename> -e "test name"`
|
92
97
|
|
93
|
-
$ rspec spec/ransack/search_spec.rb -e "accepts a context option"
|
98
|
+
$ bundle exec rspec spec/ransack/search_spec.rb -e "accepts a context option"
|
94
99
|
|
95
|
-
5. Hack away! Please use Ruby features that are compatible down to Ruby
|
96
|
-
Since version 1
|
100
|
+
5. Hack away! Please use Ruby features that are compatible down to Ruby 2.3.
|
101
|
+
Since version 2.3.1, Ransack no longer maintains Ruby 2.2 compatibility.
|
97
102
|
|
98
103
|
6. Add tests for your changes. Only refactoring and documentation changes
|
99
104
|
require no new tests. If you are adding functionality or fixing a bug, we
|
data/Gemfile
CHANGED
@@ -3,45 +3,49 @@ gemspec
|
|
3
3
|
|
4
4
|
gem 'rake'
|
5
5
|
|
6
|
-
rails = ENV['RAILS'] || '
|
6
|
+
rails = ENV['RAILS'] || '6-0-stable'
|
7
7
|
|
8
|
-
|
8
|
+
rails_version = case rails
|
9
|
+
when /\// # A path
|
10
|
+
File.read(File.join(rails, "RAILS_VERSION"))
|
11
|
+
when /^v/ # A tagged version
|
12
|
+
rails.gsub(/^v/, '')
|
13
|
+
else
|
14
|
+
rails
|
15
|
+
end
|
9
16
|
|
10
|
-
|
11
|
-
gem '
|
17
|
+
gem 'faker', '~> 1.0'
|
18
|
+
gem 'sqlite3', ::Gem::Version.new(rails_version) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
|
19
|
+
gem 'pg', '~> 1.0'
|
20
|
+
gem 'pry', '~> 0.12.2'
|
21
|
+
gem 'byebug'
|
12
22
|
|
13
23
|
case rails
|
14
24
|
when /\// # A path
|
15
25
|
gem 'activesupport', path: "#{rails}/activesupport"
|
26
|
+
gem 'activemodel', path: "#{rails}/activemodel"
|
16
27
|
gem 'activerecord', path: "#{rails}/activerecord", require: false
|
17
28
|
gem 'actionpack', path: "#{rails}/actionpack"
|
29
|
+
gem 'actionview', path: "#{rails}/actionview"
|
18
30
|
when /^v/ # A tagged version
|
19
|
-
git '
|
31
|
+
git 'https://github.com/rails/rails.git', :tag => rails do
|
20
32
|
gem 'activesupport'
|
21
33
|
gem 'activemodel'
|
22
34
|
gem 'activerecord', require: false
|
23
35
|
gem 'actionpack'
|
24
36
|
end
|
25
|
-
if rails >= 'v5.2.0'
|
26
|
-
gem 'mysql2', '~> 0.4.4'
|
27
|
-
end
|
28
37
|
else
|
29
|
-
git '
|
38
|
+
git 'https://github.com/rails/rails.git', :branch => rails do
|
30
39
|
gem 'activesupport'
|
31
40
|
gem 'activemodel'
|
32
41
|
gem 'activerecord', require: false
|
33
42
|
gem 'actionpack'
|
34
43
|
end
|
35
|
-
if rails == '3-0-stable'
|
36
|
-
gem 'mysql2', '< 0.3'
|
37
|
-
end
|
38
|
-
if rails == '5-2-stable'
|
39
|
-
gem 'mysql2', '~> 0.4.4'
|
40
|
-
end
|
41
44
|
end
|
45
|
+
gem 'mysql2', '~> 0.5.2'
|
42
46
|
|
43
47
|
group :test do
|
44
|
-
|
45
|
-
gem '
|
48
|
+
gem 'machinist', '~> 1.0.6'
|
49
|
+
gem 'rspec', '~> 3'
|
46
50
|
gem 'simplecov', :require => false
|
47
51
|
end
|
data/README.md
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
# ![Ransack](./logo/ransack-h.png "Ransack")
|
2
2
|
|
3
|
+
**MAINTAINER WANTED**
|
4
|
+
|
5
|
+
Please see the [Maintainer wanted issue](https://github.com/activerecord-hackery/ransack/issues/1159) if you are interested.
|
6
|
+
|
3
7
|
[![Build Status](https://travis-ci.org/activerecord-hackery/ransack.svg)](https://travis-ci.org/activerecord-hackery/ransack)
|
4
8
|
[![Gem Version](https://badge.fury.io/rb/ransack.svg)](http://badge.fury.io/rb/ransack)
|
5
9
|
[![Code Climate](https://codeclimate.com/github/activerecord-hackery/ransack/badges/gpa.svg)](https://codeclimate.com/github/activerecord-hackery/ransack)
|
6
|
-
|
7
|
-
Ransack is a rewrite of [MetaSearch](https://github.com/activerecord-hackery/meta_search)
|
8
|
-
created by [Ernie Miller](http://twitter.com/erniemiller)
|
9
|
-
and developed/maintained for years by
|
10
|
-
[Jon Atack](http://twitter.com/jonatack) and
|
11
|
-
[Ryan Bigg](http://twitter.com/ryanbigg) with the help of a great group of
|
12
|
-
[contributors](https://github.com/activerecord-hackery/ransack/graphs/contributors). Ransack's logo is designed by [Anıl Kılıç](https://github.com/anilkilic).
|
13
|
-
While it supports many of the same features as MetaSearch, its underlying
|
14
|
-
implementation differs greatly from MetaSearch,
|
15
|
-
and backwards compatibility is not a design goal.
|
10
|
+
[![Backers on Open Collective](https://opencollective.com/ransack/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/ransack/sponsors/badge.svg)](#sponsors)
|
16
11
|
|
17
12
|
Ransack enables the creation of both
|
18
13
|
[simple](http://ransack-demo.herokuapp.com) and
|
@@ -24,21 +19,9 @@ or controller layer, you're probably not looking for Ransack (or MetaSearch,
|
|
24
19
|
for that matter). Try [Squeel](https://github.com/activerecord-hackery/squeel)
|
25
20
|
instead.
|
26
21
|
|
27
|
-
If you're viewing this at
|
28
|
-
[github.com/activerecord-hackery/ransack](https://github.com/activerecord-hackery/ransack),
|
29
|
-
you're reading the documentation for the master branch with the latest features.
|
30
|
-
[View documentation for the last release (2.0.0).](https://github.com/activerecord-hackery/ransack/tree/v2.0.0)
|
31
|
-
|
32
22
|
## Getting started
|
33
23
|
|
34
|
-
Ransack is compatible with Rails 5.0, 5.1 and 5.2 on Ruby 2.
|
35
|
-
If you are using Rails <5.0 use the 1.8 line of Ransack.
|
36
|
-
If you are using Ruby 1.8 or an earlier JRuby and run into compatibility
|
37
|
-
issues, you can use an earlier version of Ransack, say, up to 1.3.0.
|
38
|
-
|
39
|
-
Ransack works out-of-the-box with Active Record and also features limited
|
40
|
-
support for Mongoid 4 and 5 (without associations, further details
|
41
|
-
[below](https://github.com/activerecord-hackery/ransack#mongoid)).
|
24
|
+
Ransack is compatible with Rails 6.0, 5.0, 5.1 and 5.2 on Ruby 2.3 and later.
|
42
25
|
|
43
26
|
In your Gemfile, for the last officially released gem:
|
44
27
|
|
@@ -458,13 +441,10 @@ List of all possible predicates
|
|
458
441
|
| `*_lteq_any` | Less than or equal to any | |
|
459
442
|
| `*_gt_any` | Greater than any | |
|
460
443
|
| `*_gteq_any` | Greater than or equal to any | |
|
461
|
-
| `*_matches_any` | `*_does_not_match_any` | same as above but with `LIKE` |
|
462
444
|
| `*_lt_all` | Less than all | SQL: `col < value1 AND col < value2` |
|
463
445
|
| `*_lteq_all` | Less than or equal to all | |
|
464
446
|
| `*_gt_all` | Greater than all | |
|
465
447
|
| `*_gteq_all` | Greater than or equal to all | |
|
466
|
-
| `*_matches_all` | Matches all | same as above but with `LIKE` |
|
467
|
-
| `*_does_not_match_all` | Does not match all | |
|
468
448
|
| `*_not_eq_all` | none of values in a set | |
|
469
449
|
| `*_start` | Starts with | SQL: `col LIKE 'value%'` |
|
470
450
|
| `*_not_start` | Does not start with | |
|
@@ -484,6 +464,12 @@ List of all possible predicates
|
|
484
464
|
| `*_not_cont` | Does not contain |
|
485
465
|
| `*_not_cont_any` | Does not contain any of | |
|
486
466
|
| `*_not_cont_all` | Does not contain all of | |
|
467
|
+
| `*_i_cont` | Contains value with case insensitive | uses `ILIKE` |
|
468
|
+
| `*_i_cont_any` | Contains any of values with case insensitive | |
|
469
|
+
| `*_i_cont_all` | Contains all of values with case insensitive | |
|
470
|
+
| `*_not_i_cont` | Does not contain with case insensitive |
|
471
|
+
| `*_not_i_cont_any` | Does not contain any of values with case insensitive | |
|
472
|
+
| `*_not_i_cont_all` | Does not contain all of values with case insensitive | |
|
487
473
|
| `*_true` | is true | |
|
488
474
|
| `*_false` | is false | |
|
489
475
|
|
@@ -716,8 +702,6 @@ class Employee < ActiveRecord::Base
|
|
716
702
|
%i(activated hired_since)
|
717
703
|
end
|
718
704
|
end
|
719
|
-
|
720
|
-
private_class_method :ransackable_scopes
|
721
705
|
end
|
722
706
|
|
723
707
|
Employee.ransack({ activated: true, hired_since: '2013-01-01' })
|
@@ -752,7 +736,7 @@ To turn this off on a per-scope basis Ransack adds the following method to
|
|
752
736
|
Add the scope you wish to bypass this behavior to ransackable_scopes_skip_sanitize_args:
|
753
737
|
|
754
738
|
```ruby
|
755
|
-
def ransackable_scopes_skip_sanitize_args
|
739
|
+
def self.ransackable_scopes_skip_sanitize_args
|
756
740
|
[:scope_to_skip_sanitize_args]
|
757
741
|
end
|
758
742
|
```
|
@@ -923,6 +907,7 @@ In other words: `Major.Minor.Patch`.
|
|
923
907
|
|
924
908
|
To support the project:
|
925
909
|
|
910
|
+
* Consider supporting via [Open Collective](https://opencollective.com/ransack/backers/badge.svg)
|
926
911
|
* Use Ransack in your apps, and let us know if you encounter anything that's
|
927
912
|
broken or missing. A failing spec to demonstrate the issue is awesome. A pull
|
928
913
|
request with passing tests is even better!
|
@@ -933,3 +918,45 @@ directly related to bug reports, pull requests, or documentation improvements.
|
|
933
918
|
* Spread the word on Twitter, Facebook, and elsewhere if Ransack's been useful
|
934
919
|
to you. The more people who are using the project, the quicker we can find and
|
935
920
|
fix bugs!
|
921
|
+
|
922
|
+
## Contributors
|
923
|
+
|
924
|
+
This project exists thanks to all the people who contribute. <img src="https://opencollective.com/ransack/contributors.svg?width=890&button=false" />
|
925
|
+
|
926
|
+
Ransack is a rewrite of [MetaSearch](https://github.com/activerecord-hackery/meta_search)
|
927
|
+
created by [Ernie Miller](http://twitter.com/erniemiller)
|
928
|
+
and developed/maintained by:
|
929
|
+
|
930
|
+
- [Greg Molnar](https://github.com/gregmolnar)
|
931
|
+
- [Deivid Rodriguez](https://github.com/deivid-rodriguez)
|
932
|
+
- [Sean Carroll](https://github.com/seanfcarroll)
|
933
|
+
- [Jon Atack](http://twitter.com/jonatack)
|
934
|
+
- [Ryan Bigg](http://twitter.com/ryanbigg)
|
935
|
+
- a great group of [contributors](https://github.com/activerecord-hackery/ransack/graphs/contributors).
|
936
|
+
- Ransack's logo is designed by [Anıl Kılıç](https://github.com/anilkilic).
|
937
|
+
|
938
|
+
While it supports many of the same features as MetaSearch, its underlying implementation differs greatly from MetaSearch, and backwards compatibility is not a design goal.
|
939
|
+
|
940
|
+
|
941
|
+
|
942
|
+
## Backers
|
943
|
+
|
944
|
+
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/ransack#backer)]
|
945
|
+
|
946
|
+
<a href="https://opencollective.com/ransack#backers" target="_blank"><img src="https://opencollective.com/ransack/backers.svg?width=890"></a>
|
947
|
+
|
948
|
+
|
949
|
+
## Sponsors
|
950
|
+
|
951
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/ransack#sponsor)]
|
952
|
+
|
953
|
+
<a href="https://opencollective.com/ransack/sponsor/0/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/0/avatar.svg"></a>
|
954
|
+
<a href="https://opencollective.com/ransack/sponsor/1/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/1/avatar.svg"></a>
|
955
|
+
<a href="https://opencollective.com/ransack/sponsor/2/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/2/avatar.svg"></a>
|
956
|
+
<a href="https://opencollective.com/ransack/sponsor/3/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/3/avatar.svg"></a>
|
957
|
+
<a href="https://opencollective.com/ransack/sponsor/4/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/4/avatar.svg"></a>
|
958
|
+
<a href="https://opencollective.com/ransack/sponsor/5/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/5/avatar.svg"></a>
|
959
|
+
<a href="https://opencollective.com/ransack/sponsor/6/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/6/avatar.svg"></a>
|
960
|
+
<a href="https://opencollective.com/ransack/sponsor/7/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/7/avatar.svg"></a>
|
961
|
+
<a href="https://opencollective.com/ransack/sponsor/8/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/8/avatar.svg"></a>
|
962
|
+
<a href="https://opencollective.com/ransack/sponsor/9/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/9/avatar.svg"></a>
|
data/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_association.rb
RENAMED
@@ -1,5 +1,3 @@
|
|
1
|
-
# active_record_5.2.1_ruby_2/join_association.rb
|
2
|
-
|
3
1
|
module Polyamorous
|
4
2
|
module JoinAssociationExtensions
|
5
3
|
include SwappingReflectionClass
|
@@ -19,13 +17,8 @@ module Polyamorous
|
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
|
-
def
|
23
|
-
|
24
|
-
super(klass, table, key, foreign_table, foreign_key)
|
25
|
-
.and(foreign_table[reflection.foreign_type].eq(reflection.klass.name))
|
26
|
-
else
|
27
|
-
super(klass, table, key, foreign_table, foreign_key)
|
28
|
-
end
|
20
|
+
def ==(other)
|
21
|
+
base_klass == other.base_klass
|
29
22
|
end
|
30
23
|
end
|
31
24
|
end
|
data/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_dependency.rb
RENAMED
@@ -1,9 +1,6 @@
|
|
1
|
-
# active_record_5.2.1_ruby_2/join_dependency.rb
|
2
|
-
|
3
1
|
module Polyamorous
|
4
2
|
module JoinDependencyExtensions
|
5
3
|
# Replaces ActiveRecord::Associations::JoinDependency#build
|
6
|
-
#
|
7
4
|
def build(associations, base_klass)
|
8
5
|
associations.map do |name, right|
|
9
6
|
if name.is_a? Join
|
@@ -30,6 +27,31 @@ module Polyamorous
|
|
30
27
|
end
|
31
28
|
end
|
32
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
|
+
|
33
55
|
module ClassMethods
|
34
56
|
# Prepended before ActiveRecord::Associations::JoinDependency#walk_tree
|
35
57
|
#
|