pluck_each 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pluck_each.rb +3 -6
- data/lib/pluck_each/version.rb +1 -1
- data/spec/pluck_each_spec.rb +16 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ea18fa9a2707621fb6430795c4c6047b337fec
|
4
|
+
data.tar.gz: 7091ef9abf6df62714e4f0f828303b482c82a765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e11526748776eeb71864eb443c1cc16526b4c5e233d9488a9a207839270f8b4985a36de51942ed33cf5c6cec72ff5a236de8a28ff1eb46be6471b28032cb1514
|
7
|
+
data.tar.gz: 349cb861579f0c721068dc77f18113c71468f961c91dc3c887d49fc1e190874212c2879b26531a8836b18c6058caf9f0ae97e76a45660eb5982ccdc3a78c7cfd
|
data/lib/pluck_each.rb
CHANGED
@@ -53,12 +53,9 @@ module ActiveRecord
|
|
53
53
|
|
54
54
|
break if batch.size < batch_size
|
55
55
|
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
else
|
60
|
-
batch_relation = relation.where("#{primary_key} > ?", primary_key_offset)
|
61
|
-
end
|
56
|
+
# Rails 5 introduced "arel_attribute" but keeps support for "table" so using
|
57
|
+
# "table" as the basis for this for now
|
58
|
+
batch_relation = relation.where(table[primary_key].gt(primary_key_offset))
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
data/lib/pluck_each/version.rb
CHANGED
data/spec/pluck_each_spec.rb
CHANGED
@@ -23,11 +23,27 @@ describe PluckEach do
|
|
23
23
|
describe 'pluck_each' do
|
24
24
|
before do
|
25
25
|
User.delete_all
|
26
|
+
Product.delete_all
|
27
|
+
|
26
28
|
User.create(:first_name => '1', :last_name => '1')
|
27
29
|
User.create(:first_name => '2', :last_name => '2')
|
28
30
|
User.create(:first_name => '3', :last_name => '3')
|
29
31
|
User.create(:first_name => '4', :last_name => '4')
|
30
32
|
User.create(:first_name => '5', :last_name => '5')
|
33
|
+
Product.create(:name => "1", :value => 1, :user_id => User.first.id)
|
34
|
+
Product.create(:name => "2", :value => 2, :user_id => User.first.id)
|
35
|
+
Product.create(:name => "3", :value => 3, :user_id => User.first.id)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'plucks :id from scope on association' do
|
39
|
+
values = []
|
40
|
+
user = User.first
|
41
|
+
user.products.pluck_each(:name) do |name|
|
42
|
+
values << name
|
43
|
+
end
|
44
|
+
|
45
|
+
values.sort!
|
46
|
+
values.must_equal ["1", "2", "3"]
|
31
47
|
end
|
32
48
|
|
33
49
|
it 'plucks :id when only field requested' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluck_each
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.5.1
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: pluck_each and plucK_in_batches ... should behave like find_each and find_in_batches
|