deep_pluck 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -4
- data/CHANGELOG.md +59 -54
- data/README.md +3 -2
- data/lib/deep_pluck/model.rb +17 -1
- data/lib/deep_pluck/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7bbd3c0df3b323529a252d7d56fa596b4f85923b06b54a04560826b2793b8fe
|
4
|
+
data.tar.gz: 1261968870077b5cb7f4db0c56e1045f513b6caa2a76c028a9235535635704c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9196070fb6189bc2e2b8da44976fd0ecd5dead243075a8abe66ae524af674d1f8e99f74abb0d2337bf65e42f85688ef20ba07c4b422f0179750b50d35421d3
|
7
|
+
data.tar.gz: 34302f6ca57406fa7c61635fd0e2465cafef8b41da426b62f23fee1635df506a9d1750b2506653b0d307d2d1a599a83d23986ad9efc772c2ad66dd5792bdbef1
|
data/.travis.yml
CHANGED
@@ -6,6 +6,7 @@ language: ruby
|
|
6
6
|
rvm:
|
7
7
|
- 2.2
|
8
8
|
- 2.6
|
9
|
+
- 2.7
|
9
10
|
gemfile:
|
10
11
|
- gemfiles/3.2.gemfile
|
11
12
|
- gemfiles/4.2.gemfile
|
@@ -17,13 +18,17 @@ matrix:
|
|
17
18
|
exclude:
|
18
19
|
- gemfile: gemfiles/3.2.gemfile
|
19
20
|
rvm: 2.6
|
20
|
-
- gemfile: gemfiles/
|
21
|
-
rvm: 2.
|
21
|
+
- gemfile: gemfiles/3.2.gemfile
|
22
|
+
rvm: 2.7
|
23
|
+
- gemfile: gemfiles/4.2.gemfile
|
24
|
+
rvm: 2.7
|
22
25
|
- gemfile: gemfiles/6.0.gemfile
|
23
26
|
rvm: 2.2
|
24
27
|
before_install:
|
25
|
-
-
|
26
|
-
|
28
|
+
- if `ruby -e 'exit(RUBY_VERSION.to_f < 2.7)'`; then
|
29
|
+
gem i rubygems-update -v '< 3' && update_rubygems;
|
30
|
+
gem install bundler -v '< 2';
|
31
|
+
fi
|
27
32
|
- gem --version
|
28
33
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
29
34
|
- chmod +x ./cc-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -1,54 +1,59 @@
|
|
1
|
-
## Change Log
|
2
|
-
|
3
|
-
### [v1.1.
|
4
|
-
- [#
|
5
|
-
|
6
|
-
|
7
|
-
- [#
|
8
|
-
- [#
|
9
|
-
|
10
|
-
|
11
|
-
- [#
|
12
|
-
|
13
|
-
|
14
|
-
- [#
|
15
|
-
- [#
|
16
|
-
- [#
|
17
|
-
|
18
|
-
|
19
|
-
- [#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
- [#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- [#
|
28
|
-
|
29
|
-
### [
|
30
|
-
- [#
|
31
|
-
|
32
|
-
### [v0.1.
|
33
|
-
- [#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
- [#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- [#
|
42
|
-
|
43
|
-
### [v0.1.
|
44
|
-
- [#
|
45
|
-
|
46
|
-
### [v0.0
|
47
|
-
- [#
|
48
|
-
|
49
|
-
### [v0.0.
|
50
|
-
- [#
|
51
|
-
|
52
|
-
### [v0.0.
|
53
|
-
- [#
|
54
|
-
|
1
|
+
## Change Log
|
2
|
+
|
3
|
+
### [v1.1.3](https://github.com/khiav223577/deep_pluck/compare/v1.1.2...v1.1.3) 2019/12/17
|
4
|
+
- [#34](https://github.com/khiav223577/deep_pluck/pull/34) Support for plucking directly on a has_one through association (@khiav223577)
|
5
|
+
|
6
|
+
### [v1.1.2](https://github.com/khiav223577/deep_pluck/compare/v1.1.1...v1.1.2) 2019/09/25
|
7
|
+
- [#32](https://github.com/khiav223577/deep_pluck/pull/32) Remove unneeded `PreloadedModel` (@khiav223577)
|
8
|
+
- [#31](https://github.com/khiav223577/deep_pluck/pull/31) Support Rails 6.0 (@khiav223577)
|
9
|
+
- [#30](https://github.com/khiav223577/deep_pluck/pull/30) Lock sqlite3 version to 1.3.x (@khiav223577)
|
10
|
+
- [#28](https://github.com/khiav223577/deep_pluck/pull/28) Fix: broken test cases after bundler 2.0 was released (@khiav223577)
|
11
|
+
- [#27](https://github.com/khiav223577/deep_pluck/pull/27) Remove deprecated codeclimate-test-reporter gem and update travis config (@khiav223577)
|
12
|
+
|
13
|
+
### [v1.1.1](https://github.com/khiav223577/deep_pluck/compare/v1.1.0...v1.1.1) 2018/07/08
|
14
|
+
- [#26](https://github.com/khiav223577/deep_pluck/pull/26) Fix: `id` may disappear when plucking at model instance (@khiav223577)
|
15
|
+
- [#25](https://github.com/khiav223577/deep_pluck/pull/25) Refactor - move models definition to separate files (@khiav223577)
|
16
|
+
- [#24](https://github.com/khiav223577/deep_pluck/pull/24) test Rails 5.2 (@khiav223577)
|
17
|
+
- [#23](https://github.com/khiav223577/deep_pluck/pull/23) should test both 5.0.x and 5.1.x (@khiav223577)
|
18
|
+
- [#22](https://github.com/khiav223577/deep_pluck/pull/22) #deep_pluck at active model without plucking deeply will cause ArgumentError (@khiav223577)
|
19
|
+
- [#20](https://github.com/khiav223577/deep_pluck/pull/20) [ENHANCE] Eliminate Extra Select Loop in Hash Lookup (@berniechiu)
|
20
|
+
|
21
|
+
### [v1.1.0](https://github.com/khiav223577/deep_pluck/compare/v1.0.3...v1.1.0) 2018/02/15
|
22
|
+
- [#19](https://github.com/khiav223577/deep_pluck/pull/19) Support deep_pluck at active model (@khiav223577)
|
23
|
+
- [#18](https://github.com/khiav223577/deep_pluck/pull/18) Add rubocop and Improve code quality (@khiav223577)
|
24
|
+
|
25
|
+
### [v1.0.3](https://github.com/khiav223577/deep_pluck/compare/v1.0.2...v1.0.3) 2017/06/30
|
26
|
+
- [#15](https://github.com/khiav223577/deep_pluck/pull/15) test deep_pluck in rails 5.1.x (@khiav223577)
|
27
|
+
- [#14](https://github.com/khiav223577/deep_pluck/pull/14) Handle polymorphic associations correctly. (@Bogadon)
|
28
|
+
|
29
|
+
### [v1.0.0](https://github.com/khiav223577/deep_pluck/compare/v0.1.4...v1.0.0) 2017/03/28
|
30
|
+
- [#12](https://github.com/khiav223577/deep_pluck/pull/12) reduce cyclomatic complexity in model.rb (@khiav223577)
|
31
|
+
|
32
|
+
### [v0.1.4](https://github.com/khiav223577/deep_pluck/compare/v0.1.3...v0.1.4) 2017/03/27
|
33
|
+
- [#11](https://github.com/khiav223577/deep_pluck/pull/11) Fix conditional associations (@khiav223577)
|
34
|
+
|
35
|
+
### [v0.1.3](https://github.com/khiav223577/deep_pluck/compare/v0.1.2...v0.1.3) 2017/03/20
|
36
|
+
- [#10](https://github.com/khiav223577/deep_pluck/pull/10) fix custom foreign_key, custom primary_key issues (@khiav223577)
|
37
|
+
- [#9](https://github.com/khiav223577/deep_pluck/pull/9) fix has_and_belongs_to_many (@khiav223577)
|
38
|
+
|
39
|
+
### [v0.1.2](https://github.com/khiav223577/deep_pluck/compare/v0.1.1...v0.1.2) 2017/03/17
|
40
|
+
- [#8](https://github.com/khiav223577/deep_pluck/pull/8) fix some need columns is missing (@khiav223577)
|
41
|
+
- [#7](https://github.com/khiav223577/deep_pluck/pull/7) raise error message when association not found (@khiav223577)
|
42
|
+
|
43
|
+
### [v0.1.1](https://github.com/khiav223577/deep_pluck/compare/v0.1.0...v0.1.1) 2017/03/16
|
44
|
+
- [#6](https://github.com/khiav223577/deep_pluck/pull/6) fix deep_pluck with #joins (@khiav223577)
|
45
|
+
|
46
|
+
### [v0.1.0](https://github.com/khiav223577/deep_pluck/compare/v0.0.4...v0.1.0) 2017/03/15
|
47
|
+
- [#5](https://github.com/khiav223577/deep_pluck/pull/5) Support pluck many-to-many associations (@khiav223577)
|
48
|
+
|
49
|
+
### [v0.0.4](https://github.com/khiav223577/deep_pluck/compare/v0.0.3...v0.0.4) 2017/03/14
|
50
|
+
- [#4](https://github.com/khiav223577/deep_pluck/pull/4) Fix use deep_pluck on NullRelation will raise exception and prevent unneeded query. (@khiav223577)
|
51
|
+
|
52
|
+
### [v0.0.3](https://github.com/khiav223577/deep_pluck/compare/v0.0.2...v0.0.3) 2017/03/06
|
53
|
+
- [#3](https://github.com/khiav223577/deep_pluck/pull/3) support more than two level (@khiav223577)
|
54
|
+
|
55
|
+
### [v0.0.2](https://github.com/khiav223577/deep_pluck/compare/v0.0.1...v0.0.2) 2017/03/06
|
56
|
+
- [#2](https://github.com/khiav223577/deep_pluck/pull/2) The result of has_one association should not be array (@khiav223577)
|
57
|
+
|
58
|
+
### v0.0.1 2017/03/04
|
59
|
+
- [#1](https://github.com/khiav223577/deep_pluck/pull/1) deep pluck (@khiav223577)
|
data/README.md
CHANGED
data/lib/deep_pluck/model.rb
CHANGED
@@ -119,7 +119,23 @@ module DeepPluck
|
|
119
119
|
query[reflect.type] = reflect.active_record.to_s if reflect.type
|
120
120
|
|
121
121
|
return get_association_scope(reflect).where(query) if use_association_to_query?(reflect)
|
122
|
-
|
122
|
+
|
123
|
+
join_table = get_join_table(reflect)
|
124
|
+
join_table = backtrace_possible_association(relation, join_table)
|
125
|
+
|
126
|
+
return relation.joins(join_table).where(query)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Let city has_many :users, through: :schools
|
130
|
+
# And the query is: City.deep_pluck('users' => :name)
|
131
|
+
# We want to get the users data via `User.joins(:school).where(city_id: city_ids)`
|
132
|
+
# But get_join_table(reflect) returns `:schools` not :school
|
133
|
+
# No idea how to get the right association, so we try singularize or pluralize it.
|
134
|
+
def backtrace_possible_association(relation, join_table)
|
135
|
+
return join_table if relation.reflect_on_association(join_table)
|
136
|
+
join_table.to_s.singularize.to_sym.tap{|s| return s if relation.reflect_on_association(s) }
|
137
|
+
join_table.to_s.pluralize.to_sym.tap{|s| return s if relation.reflect_on_association(s) }
|
138
|
+
return nil
|
123
139
|
end
|
124
140
|
|
125
141
|
def set_includes_data(parent, column_name, model)
|
data/lib/deep_pluck/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_pluck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|