left_joins 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +9 -9
- data/.travis.yml +23 -23
- data/CHANGELOG.md +24 -21
- data/CODE_OF_CONDUCT.md +48 -48
- data/Gemfile +13 -13
- data/LICENSE.txt +21 -21
- data/README.md +46 -46
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/gemfiles/3.2.gemfile +12 -12
- data/gemfiles/4.0.gemfile +12 -12
- data/gemfiles/4.2.gemfile +12 -12
- data/gemfiles/5.0.gemfile +12 -12
- data/gemfiles/5.1.gemfile +12 -12
- data/gemfiles/5.2.gemfile +12 -12
- data/left_joins.gemspec +45 -45
- data/lib/left_joins.rb +178 -187
- data/lib/left_joins/version.rb +3 -3
- data/lib/left_joins_for_rails_3.rb +20 -20
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: ec2033d0f2d52843771477d957bd0033a0ce9871
|
|
4
|
+
data.tar.gz: 74120203c3dd31a28b9622585b9bae16b5993ab6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10c48e27f9e0f2bc35fb04077d1d470268d2b2405af120cee090870466953d170e0c5f70376f150f96cca66e8499c21a3f74d6d3b05e40b3640950b4ba2bce09
|
|
7
|
+
data.tar.gz: cdcc7b9a4ab4b579131354b8ef7abf9e0750927b5c7778d33167526c9cbae5eaa73ed946ab195fcbfdb6c65f77f1deb04749e13314d3bc19bd4a5b661ad2c73c
|
data/.gitignore
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/Gemfile.lock
|
|
4
|
-
/_yardoc/
|
|
5
|
-
/coverage/
|
|
6
|
-
/doc/
|
|
7
|
-
/pkg/
|
|
8
|
-
/spec/reports/
|
|
9
|
-
/tmp/
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/Gemfile.lock
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/coverage/
|
|
6
|
+
/doc/
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/tmp/
|
data/.travis.yml
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.2
|
|
4
|
-
- 2.3
|
|
5
|
-
sudo: required
|
|
6
|
-
dist: trusty
|
|
7
|
-
before_install:
|
|
8
|
-
- gem i rubygems-update -v '<3' && update_rubygems
|
|
9
|
-
- gem install bundler -v 1.17.3
|
|
10
|
-
- gem --version
|
|
11
|
-
gemfile:
|
|
12
|
-
- gemfiles/3.2.gemfile
|
|
13
|
-
- gemfiles/4.0.gemfile
|
|
14
|
-
- gemfiles/4.2.gemfile
|
|
15
|
-
- gemfiles/5.0.gemfile
|
|
16
|
-
- gemfiles/5.1.gemfile
|
|
17
|
-
- gemfiles/5.2.gemfile
|
|
18
|
-
addons:
|
|
19
|
-
code_climate:
|
|
20
|
-
repo_token: 9f3ed69eaf4cd5087f34c19d2e74f2457cdd1ae031cc43d0c1be308675e95823
|
|
21
|
-
after_success:
|
|
22
|
-
- bundle exec codeclimate-test-reporter
|
|
23
|
-
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 2.2
|
|
4
|
+
- 2.3
|
|
5
|
+
sudo: required
|
|
6
|
+
dist: trusty
|
|
7
|
+
before_install:
|
|
8
|
+
- gem i rubygems-update -v '<3' && update_rubygems
|
|
9
|
+
- gem install bundler -v 1.17.3
|
|
10
|
+
- gem --version
|
|
11
|
+
gemfile:
|
|
12
|
+
- gemfiles/3.2.gemfile
|
|
13
|
+
- gemfiles/4.0.gemfile
|
|
14
|
+
- gemfiles/4.2.gemfile
|
|
15
|
+
- gemfiles/5.0.gemfile
|
|
16
|
+
- gemfiles/5.1.gemfile
|
|
17
|
+
- gemfiles/5.2.gemfile
|
|
18
|
+
addons:
|
|
19
|
+
code_climate:
|
|
20
|
+
repo_token: 9f3ed69eaf4cd5087f34c19d2e74f2457cdd1ae031cc43d0c1be308675e95823
|
|
21
|
+
after_success:
|
|
22
|
+
- bundle exec codeclimate-test-reporter
|
|
23
|
+
|
data/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
## Change Log
|
|
2
|
-
|
|
3
|
-
### [v1.0.
|
|
4
|
-
- [#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [#
|
|
10
|
-
|
|
11
|
-
### [v1.0.
|
|
12
|
-
- [#
|
|
13
|
-
|
|
14
|
-
### [v1.0.
|
|
15
|
-
- [#
|
|
16
|
-
|
|
17
|
-
### [v1.0.
|
|
18
|
-
- [#
|
|
19
|
-
|
|
20
|
-
### [v1.0.
|
|
21
|
-
- [#
|
|
1
|
+
## Change Log
|
|
2
|
+
|
|
3
|
+
### [v1.0.6](https://github.com/khiav223577/left_joins/compare/v1.0.5...v1.0.6) 2019/06/22
|
|
4
|
+
- [#12](https://github.com/khiav223577/left_joins/pull/12) Fix: update with left joins (@khiav223577)
|
|
5
|
+
|
|
6
|
+
### [v1.0.5](https://github.com/khiav223577/left_joins/compare/v1.0.4...v1.0.5) 2019/04/11
|
|
7
|
+
- [#9](https://github.com/khiav223577/left_joins/pull/9) left_joins_values should not be nil (@khiav223577)
|
|
8
|
+
- [#10](https://github.com/khiav223577/left_joins/pull/10) Lock sqlite3 version to 1.3 (@khiav223577)
|
|
9
|
+
- [#8](https://github.com/khiav223577/left_joins/pull/8) Fix: broken test cases after bundler 2.0 was released (@khiav223577)
|
|
10
|
+
|
|
11
|
+
### [v1.0.4](https://github.com/khiav223577/left_joins/compare/v1.0.3...v1.0.4) 2018/07/18
|
|
12
|
+
- [#7](https://github.com/khiav223577/left_joins/pull/7) Fix: eager_load is broken (@khiav223577)
|
|
13
|
+
|
|
14
|
+
### [v1.0.3](https://github.com/khiav223577/left_joins/compare/v1.0.2...v1.0.3) 2018/06/30
|
|
15
|
+
- [#5](https://github.com/khiav223577/left_joins/pull/5) Fix: JoinDependency#make_constraints is not defined in Rails 4.0 (@khiav223577)
|
|
16
|
+
|
|
17
|
+
### [v1.0.2](https://github.com/khiav223577/left_joins/compare/v1.0.1...v1.0.2) 2018/01/12
|
|
18
|
+
- [#3](https://github.com/khiav223577/left_joins/pull/3) fix missing left joins when using in association condition (@khiav223577)
|
|
19
|
+
|
|
20
|
+
### [v1.0.1](https://github.com/khiav223577/left_joins/compare/v1.0.0...v1.0.1) 2017/12/25
|
|
21
|
+
- [#2](https://github.com/khiav223577/left_joins/pull/2) Fix count which would sometimes force a DISTINCT (@khiav223577)
|
|
22
|
+
|
|
23
|
+
### [v1.0.0](https://github.com/khiav223577/left_joins/compare/v1.0.0...v1.0.0) 2017/12/25
|
|
24
|
+
- [#1](https://github.com/khiav223577/left_joins/pull/1) implement left joins (@khiav223577)
|
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
2
|
-
|
|
3
|
-
As contributors and maintainers of this project, and in the interest of
|
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
-
|
|
8
|
-
We are committed to making participation in this project a harassment-free
|
|
9
|
-
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
-
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
-
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
-
|
|
13
|
-
Examples of unacceptable behavior by participants include:
|
|
14
|
-
|
|
15
|
-
* The use of sexualized language or imagery
|
|
16
|
-
* Personal attacks
|
|
17
|
-
* Trolling or insulting/derogatory comments
|
|
18
|
-
* Public or private harassment
|
|
19
|
-
* Publishing other's private information, such as physical or electronic
|
|
20
|
-
addresses, without explicit permission
|
|
21
|
-
* Other unethical or unprofessional conduct
|
|
22
|
-
|
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
-
threatening, offensive, or harmful.
|
|
28
|
-
|
|
29
|
-
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
-
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
-
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
-
Conduct may be permanently removed from the project team.
|
|
33
|
-
|
|
34
|
-
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
-
when an individual is representing the project or its community.
|
|
36
|
-
|
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
-
reported by contacting a project maintainer at mrtmrt15xn@yahoo.com.tw. All
|
|
39
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
-
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
-
incident.
|
|
43
|
-
|
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
-
version 1.3.0, available at
|
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
-
|
|
48
|
-
[homepage]: http://contributor-covenant.org
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at mrtmrt15xn@yahoo.com.tw. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
49
|
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in rails_or.gemspec
|
|
4
|
-
|
|
5
|
-
gem "activerecord", "~> 3.2"
|
|
6
|
-
|
|
7
|
-
group :test do
|
|
8
|
-
gem "simplecov"
|
|
9
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
gemspec :path => "./"
|
|
13
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in rails_or.gemspec
|
|
4
|
+
|
|
5
|
+
gem "activerecord", "~> 3.2"
|
|
6
|
+
|
|
7
|
+
group :test do
|
|
8
|
+
gem "simplecov"
|
|
9
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
gemspec :path => "./"
|
|
13
|
+
|
data/LICENSE.txt
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016 khiav reoy
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 khiav reoy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
[](https://rubygems.org/gems/left_joins)
|
|
2
|
-
[](https://travis-ci.org/khiav223577/left_joins)
|
|
3
|
-
[](https://rubygems.org/gems/left_joins)
|
|
4
|
-
[](https://codeclimate.com/github/khiav223577/left_joins)
|
|
5
|
-
[](https://codeclimate.com/github/khiav223577/left_joins/coverage)
|
|
6
|
-
|
|
7
|
-
# LeftJoins
|
|
8
|
-
|
|
9
|
-
Backport `left_joins` from Rails 5 for Rails 3 and 4.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
Add this line to your application's Gemfile:
|
|
14
|
-
|
|
15
|
-
```ruby
|
|
16
|
-
gem 'left_joins'
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
And then execute:
|
|
20
|
-
|
|
21
|
-
$ bundle
|
|
22
|
-
|
|
23
|
-
Or install it yourself as:
|
|
24
|
-
|
|
25
|
-
$ gem install left_joins
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## Development
|
|
33
|
-
|
|
34
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
35
|
-
|
|
36
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
37
|
-
|
|
38
|
-
## Contributing
|
|
39
|
-
|
|
40
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/khiav223577/left_joins. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## License
|
|
44
|
-
|
|
45
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
46
|
-
|
|
1
|
+
[](https://rubygems.org/gems/left_joins)
|
|
2
|
+
[](https://travis-ci.org/khiav223577/left_joins)
|
|
3
|
+
[](https://rubygems.org/gems/left_joins)
|
|
4
|
+
[](https://codeclimate.com/github/khiav223577/left_joins)
|
|
5
|
+
[](https://codeclimate.com/github/khiav223577/left_joins/coverage)
|
|
6
|
+
|
|
7
|
+
# LeftJoins
|
|
8
|
+
|
|
9
|
+
Backport `left_joins` from Rails 5 for Rails 3 and 4.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add this line to your application's Gemfile:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem 'left_joins'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
And then execute:
|
|
20
|
+
|
|
21
|
+
$ bundle
|
|
22
|
+
|
|
23
|
+
Or install it yourself as:
|
|
24
|
+
|
|
25
|
+
$ gem install left_joins
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Development
|
|
33
|
+
|
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
35
|
+
|
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
37
|
+
|
|
38
|
+
## Contributing
|
|
39
|
+
|
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/khiav223577/left_joins. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
46
|
+
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
|
2
|
-
require "rake/testtask"
|
|
3
|
-
|
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
|
5
|
-
t.libs << "test"
|
|
6
|
-
t.libs << "lib"
|
|
7
|
-
t.test_files = FileList['test/**/*_test.rb']
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
task :default => :test
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
|
5
|
+
t.libs << "test"
|
|
6
|
+
t.libs << "lib"
|
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task :default => :test
|
data/bin/console
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "left_joins"
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "left_joins"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
set -vx
|
|
5
|
-
|
|
6
|
-
bundle install --gemfile=gemfiles/3.2.gemfile
|
|
7
|
-
|
|
8
|
-
# Do any other automated setup that you need to do here
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
set -vx
|
|
5
|
+
|
|
6
|
+
bundle install --gemfile=gemfiles/3.2.gemfile
|
|
7
|
+
|
|
8
|
+
# Do any other automated setup that you need to do here
|
data/gemfiles/3.2.gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gem "activerecord", "~> 3.2.0"
|
|
4
|
-
|
|
5
|
-
group :test do
|
|
6
|
-
gem "simplecov"
|
|
7
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
gemspec :path => "../"
|
|
12
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "activerecord", "~> 3.2.0"
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem "simplecov"
|
|
7
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.6"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
gemspec :path => "../"
|
|
12
|
+
|
data/gemfiles/4.0.gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gem "activerecord", "~> 4.0.0"
|
|
4
|
-
|
|
5
|
-
group :test do
|
|
6
|
-
gem "simplecov"
|
|
7
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
gemspec :path => "../"
|
|
12
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "activerecord", "~> 4.0.0"
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem "simplecov"
|
|
7
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.6"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
gemspec :path => "../"
|
|
12
|
+
|
data/gemfiles/4.2.gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gem "activerecord", "~> 4.2.0"
|
|
4
|
-
|
|
5
|
-
group :test do
|
|
6
|
-
gem "simplecov"
|
|
7
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
gemspec :path => "../"
|
|
12
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "activerecord", "~> 4.2.0"
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem "simplecov"
|
|
7
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.6"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
gemspec :path => "../"
|
|
12
|
+
|
data/gemfiles/5.0.gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gem "activerecord", "~> 5.0.0"
|
|
4
|
-
|
|
5
|
-
group :test do
|
|
6
|
-
gem "simplecov"
|
|
7
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
gemspec :path => "../"
|
|
12
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "activerecord", "~> 5.0.0"
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem "simplecov"
|
|
7
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.6"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
gemspec :path => "../"
|
|
12
|
+
|
data/gemfiles/5.1.gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gem "activerecord", "~> 5.1.0"
|
|
4
|
-
|
|
5
|
-
group :test do
|
|
6
|
-
gem "simplecov"
|
|
7
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
gemspec :path => "../"
|
|
12
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "activerecord", "~> 5.1.0"
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem "simplecov"
|
|
7
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.6"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
gemspec :path => "../"
|
|
12
|
+
|
data/gemfiles/5.2.gemfile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gem "activerecord", "~> 5.2.0"
|
|
4
|
-
|
|
5
|
-
group :test do
|
|
6
|
-
gem "simplecov"
|
|
7
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
gemspec :path => "../"
|
|
12
|
-
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem "activerecord", "~> 5.2.0"
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem "simplecov"
|
|
7
|
+
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
8
|
+
gem "sqlite3", "~> 1.3.6"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
gemspec :path => "../"
|
|
12
|
+
|
data/left_joins.gemspec
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'left_joins/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "left_joins"
|
|
8
|
-
spec.version = LeftJoins::VERSION
|
|
9
|
-
spec.authors = ["khiav reoy"]
|
|
10
|
-
spec.email = ["mrtmrt15xn@yahoo.com.tw"]
|
|
11
|
-
|
|
12
|
-
spec.summary = %q{Backport `left_joins` from Rails 5 for Rails 3 and 4.}
|
|
13
|
-
spec.description = %q{Backport `left_joins` from Rails 5 for Rails 3 and 4.}
|
|
14
|
-
spec.homepage = "https://github.com/khiav223577/left_joins"
|
|
15
|
-
spec.license = "MIT"
|
|
16
|
-
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
-
# delete this section to allow pushing this gem to any host.
|
|
19
|
-
#if spec.respond_to?(:metadata)
|
|
20
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
-
#else
|
|
22
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
-
#end
|
|
24
|
-
|
|
25
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
-
spec.bindir = "exe"
|
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
-
spec.require_paths = ["lib"]
|
|
29
|
-
spec.metadata = {
|
|
30
|
-
'homepage_uri' => 'https://github.com/khiav223577/left_joins',
|
|
31
|
-
'changelog_uri' => 'https://github.com/khiav223577/left_joins/blob/master/CHANGELOG.md',
|
|
32
|
-
'source_code_uri' => 'https://github.com/khiav223577/left_joins',
|
|
33
|
-
'documentation_uri' => 'http://www.rubydoc.info/gems/left_joins',
|
|
34
|
-
'bug_tracker_uri' => 'https://github.com/khiav223577/left_joins/issues',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
spec.add_development_dependency 'bundler', '>= 1.17', '< 3.x'
|
|
38
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
|
39
|
-
spec.add_development_dependency "sqlite3", "~> 1.3"
|
|
40
|
-
spec.add_development_dependency "minitest", ">= 4.2"
|
|
41
|
-
spec.add_development_dependency "pluck_all", ">= 2.0.2"
|
|
42
|
-
|
|
43
|
-
spec.add_dependency "activerecord", ">= 3"
|
|
44
|
-
|
|
45
|
-
end
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'left_joins/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "left_joins"
|
|
8
|
+
spec.version = LeftJoins::VERSION
|
|
9
|
+
spec.authors = ["khiav reoy"]
|
|
10
|
+
spec.email = ["mrtmrt15xn@yahoo.com.tw"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Backport `left_joins` from Rails 5 for Rails 3 and 4.}
|
|
13
|
+
spec.description = %q{Backport `left_joins` from Rails 5 for Rails 3 and 4.}
|
|
14
|
+
spec.homepage = "https://github.com/khiav223577/left_joins"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
#if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
#else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
#end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
spec.metadata = {
|
|
30
|
+
'homepage_uri' => 'https://github.com/khiav223577/left_joins',
|
|
31
|
+
'changelog_uri' => 'https://github.com/khiav223577/left_joins/blob/master/CHANGELOG.md',
|
|
32
|
+
'source_code_uri' => 'https://github.com/khiav223577/left_joins',
|
|
33
|
+
'documentation_uri' => 'http://www.rubydoc.info/gems/left_joins',
|
|
34
|
+
'bug_tracker_uri' => 'https://github.com/khiav223577/left_joins/issues',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
spec.add_development_dependency 'bundler', '>= 1.17', '< 3.x'
|
|
38
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
|
39
|
+
spec.add_development_dependency "sqlite3", "~> 1.3"
|
|
40
|
+
spec.add_development_dependency "minitest", ">= 4.2"
|
|
41
|
+
spec.add_development_dependency "pluck_all", ">= 2.0.2"
|
|
42
|
+
|
|
43
|
+
spec.add_dependency "activerecord", ">= 3"
|
|
44
|
+
|
|
45
|
+
end
|
data/lib/left_joins.rb
CHANGED
|
@@ -1,187 +1,178 @@
|
|
|
1
|
-
require "left_joins/version"
|
|
2
|
-
require 'active_record'
|
|
3
|
-
require 'active_record/relation'
|
|
4
|
-
|
|
5
|
-
module LeftJoins
|
|
6
|
-
IS_RAILS3_FLAG = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
|
|
7
|
-
HAS_BUILT_IN_LEFT_JOINS_METHOD = ActiveRecord::QueryMethods.method_defined?(:left_outer_joins)
|
|
8
|
-
require 'left_joins_for_rails_3' if IS_RAILS3_FLAG
|
|
9
|
-
|
|
10
|
-
class << self
|
|
11
|
-
def
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return result
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
stmt.wheres = arel.constraints
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
bvs = LeftJoins.bind_values_of(self) + bind_values
|
|
183
|
-
@klass.connection.update stmt, 'SQL', bvs
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
1
|
+
require "left_joins/version"
|
|
2
|
+
require 'active_record'
|
|
3
|
+
require 'active_record/relation'
|
|
4
|
+
|
|
5
|
+
module LeftJoins
|
|
6
|
+
IS_RAILS3_FLAG = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
|
|
7
|
+
HAS_BUILT_IN_LEFT_JOINS_METHOD = ActiveRecord::QueryMethods.method_defined?(:left_outer_joins)
|
|
8
|
+
require 'left_joins_for_rails_3' if IS_RAILS3_FLAG
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
def patch(target, method, as:)
|
|
12
|
+
return yield if target.singleton_methods.include?(method)
|
|
13
|
+
|
|
14
|
+
target.define_singleton_method(method, &as)
|
|
15
|
+
result = yield
|
|
16
|
+
target.singleton_class.send(:remove_method, method)
|
|
17
|
+
|
|
18
|
+
return result
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module ActiveRecord::QueryMethods
|
|
24
|
+
if not LeftJoins::HAS_BUILT_IN_LEFT_JOINS_METHOD
|
|
25
|
+
# ----------------------------------------------------------------
|
|
26
|
+
# ● Storing left joins values into @left_outer_joins_values
|
|
27
|
+
# ----------------------------------------------------------------
|
|
28
|
+
attr_writer :left_outer_joins_values
|
|
29
|
+
def left_outer_joins_values
|
|
30
|
+
@left_outer_joins_values ||= []
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def left_outer_joins(*args)
|
|
34
|
+
check_if_method_has_arguments!(:left_outer_joins, args)
|
|
35
|
+
|
|
36
|
+
args.compact!
|
|
37
|
+
args.flatten!
|
|
38
|
+
self.distinct_value = false
|
|
39
|
+
|
|
40
|
+
return (LeftJoins::IS_RAILS3_FLAG ? clone : spawn).left_outer_joins!(*args)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def left_outer_joins!(*args)
|
|
44
|
+
left_outer_joins_values.concat(args)
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# ----------------------------------------------------------------
|
|
49
|
+
# ● Implement left joins when building arel
|
|
50
|
+
# ----------------------------------------------------------------
|
|
51
|
+
alias_method :left_joins, :left_outer_joins
|
|
52
|
+
alias_method :build_arel_without_outer_joins, :build_arel
|
|
53
|
+
def build_arel(*args)
|
|
54
|
+
arel = build_arel_without_outer_joins(*args)
|
|
55
|
+
build_left_outer_joins(arel, @left_outer_joins_values) if @left_outer_joins_values
|
|
56
|
+
return arel
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
alias_method :build_joins_without_join_type, :build_joins
|
|
60
|
+
def build_joins(manager, joins, join_type = nil)
|
|
61
|
+
Thread.current.thread_variable_set(:left_joins_join_type, join_type)
|
|
62
|
+
result = build_joins_without_join_type(manager, joins)
|
|
63
|
+
Thread.current.thread_variable_set(:left_joins_join_type, nil)
|
|
64
|
+
return result
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def build_left_outer_joins(manager, joins)
|
|
68
|
+
result = build_joins(manager, joins, Arel::Nodes::OuterJoin)
|
|
69
|
+
return result
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class << ::ActiveRecord::Base
|
|
73
|
+
def left_joins(*args)
|
|
74
|
+
self.where('').left_joins(*args)
|
|
75
|
+
end
|
|
76
|
+
alias_method :left_outer_joins, :left_joins
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class ::ActiveRecord::Associations::JoinDependency
|
|
80
|
+
if private_method_defined?(:make_constraints)
|
|
81
|
+
alias_method :make_constraints_without_hooking_join_type, :make_constraints
|
|
82
|
+
def make_constraints(*args, join_type)
|
|
83
|
+
join_type = Thread.current.thread_variable_get(:left_joins_join_type) || join_type
|
|
84
|
+
return make_constraints_without_hooking_join_type(*args, join_type)
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
alias_method :build_without_hooking_join_type, :build
|
|
88
|
+
def build(associations, parent = nil, join_type = Arel::Nodes::InnerJoin)
|
|
89
|
+
join_type = Thread.current.thread_variable_get(:left_joins_join_type) || join_type
|
|
90
|
+
return build_without_hooking_join_type(associations, parent, join_type)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
module ActiveRecord::Calculations
|
|
96
|
+
# This method is copied from activerecord-4.2.10/lib/active_record/relation/calculations.rb
|
|
97
|
+
# and modified this line `distinct = true` to `distinct = true if distinct == nil`
|
|
98
|
+
def perform_calculation(operation, column_name, options = {})
|
|
99
|
+
# TODO: Remove options argument as soon we remove support to
|
|
100
|
+
# activerecord-deprecated_finders.
|
|
101
|
+
operation = operation.to_s.downcase
|
|
102
|
+
|
|
103
|
+
# If #count is used with #distinct / #uniq it is considered distinct. (eg. relation.distinct.count)
|
|
104
|
+
distinct = options[:distinct] || self.distinct_value
|
|
105
|
+
|
|
106
|
+
if operation == "count"
|
|
107
|
+
column_name ||= (select_for_count || :all)
|
|
108
|
+
|
|
109
|
+
unless arel.ast.grep(Arel::Nodes::OuterJoin).empty?
|
|
110
|
+
distinct = true if distinct == nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
column_name = primary_key if column_name == :all && distinct
|
|
114
|
+
distinct = nil if column_name =~ /\s*DISTINCT[\s(]+/i
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if group_values.any?
|
|
118
|
+
execute_grouped_calculation(operation, column_name, distinct)
|
|
119
|
+
else
|
|
120
|
+
execute_simple_calculation(operation, column_name, distinct)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# ----------------------------------------------------------------
|
|
128
|
+
# ● Implement left joins when merging relations
|
|
129
|
+
# ----------------------------------------------------------------
|
|
130
|
+
if not LeftJoins::IS_RAILS3_FLAG
|
|
131
|
+
require 'active_record/relation/merger'
|
|
132
|
+
class ActiveRecord::Relation
|
|
133
|
+
class Merger
|
|
134
|
+
alias_method :merge_without_left_joins, :merge
|
|
135
|
+
def merge
|
|
136
|
+
values = other.left_outer_joins_values
|
|
137
|
+
relation.left_outer_joins!(*values) if values.present?
|
|
138
|
+
return merge_without_left_joins
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
module ActiveRecord
|
|
144
|
+
module SpawnMethods
|
|
145
|
+
|
|
146
|
+
private
|
|
147
|
+
|
|
148
|
+
alias_method :relation_with_without_left_joins, :relation_with
|
|
149
|
+
def relation_with(values) # :nodoc:
|
|
150
|
+
result = relation_with_without_left_joins(values)
|
|
151
|
+
result.left_outer_joins_values = self.left_outer_joins_values
|
|
152
|
+
return result
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# ----------------------------------------------------------------
|
|
159
|
+
# ● Implement left joins in update statement
|
|
160
|
+
# ----------------------------------------------------------------
|
|
161
|
+
module ActiveRecord
|
|
162
|
+
class Relation
|
|
163
|
+
if not LeftJoins::HAS_BUILT_IN_LEFT_JOINS_METHOD
|
|
164
|
+
alias_method :update_all_without_left_joins_values, :update_all
|
|
165
|
+
|
|
166
|
+
def update_all(*args)
|
|
167
|
+
local_joins_values = joins_values.clone
|
|
168
|
+
has_left_outer_joins = left_outer_joins_values.any?
|
|
169
|
+
|
|
170
|
+
LeftJoins.patch(self, :joins_values, as: ->{ local_joins_values }) do
|
|
171
|
+
LeftJoins.patch(local_joins_values, :any?, as: ->{ super() || has_left_outer_joins }) do
|
|
172
|
+
update_all_without_left_joins_values(*args)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
data/lib/left_joins/version.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module LeftJoins
|
|
2
|
-
VERSION = "1.0.
|
|
3
|
-
end
|
|
1
|
+
module LeftJoins
|
|
2
|
+
VERSION = "1.0.7"
|
|
3
|
+
end
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# ----------------------------------------------------------------
|
|
2
|
-
# ● Implement check_if_method_has_arguments! method for Rails 3
|
|
3
|
-
# ----------------------------------------------------------------
|
|
4
|
-
module ActiveRecord::QueryMethods
|
|
5
|
-
def check_if_method_has_arguments!(method_name, args)
|
|
6
|
-
if args.blank?
|
|
7
|
-
raise ArgumentError, "The method .#{method_name}() must contain arguments."
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module ActiveRecord::Calculations
|
|
13
|
-
def distinct_value
|
|
14
|
-
uniq_value
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def distinct_value=(v)
|
|
18
|
-
self.uniq_value = v
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
# ----------------------------------------------------------------
|
|
2
|
+
# ● Implement check_if_method_has_arguments! method for Rails 3
|
|
3
|
+
# ----------------------------------------------------------------
|
|
4
|
+
module ActiveRecord::QueryMethods
|
|
5
|
+
def check_if_method_has_arguments!(method_name, args)
|
|
6
|
+
if args.blank?
|
|
7
|
+
raise ArgumentError, "The method .#{method_name}() must contain arguments."
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module ActiveRecord::Calculations
|
|
13
|
+
def distinct_value
|
|
14
|
+
uniq_value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def distinct_value=(v)
|
|
18
|
+
self.uniq_value = v
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: left_joins
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- khiav reoy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
152
152
|
version: '0'
|
|
153
153
|
requirements: []
|
|
154
154
|
rubyforge_project:
|
|
155
|
-
rubygems_version: 2.
|
|
155
|
+
rubygems_version: 2.6.14
|
|
156
156
|
signing_key:
|
|
157
157
|
specification_version: 4
|
|
158
158
|
summary: Backport `left_joins` from Rails 5 for Rails 3 and 4.
|