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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 590090a4b024b581987c5189c8d33f7705fe9deb
4
- data.tar.gz: b7902f329e25ff1a5590fdd5dcd8f757a441113f
3
+ metadata.gz: 12ea18fa9a2707621fb6430795c4c6047b337fec
4
+ data.tar.gz: 7091ef9abf6df62714e4f0f828303b482c82a765
5
5
  SHA512:
6
- metadata.gz: 1686ceb57958906c293d0330f248bea630d921cc913bc7eeb2a3d508386b5421f27e52ebaee8f7524d73a944fa8d2cf952ac41b628ef4340966e33744843fd3c
7
- data.tar.gz: f55c93814f73276331c515794f6863bc2634dee3558fc43b73f8e5191f6adb85d0a3a451b2dd31b3d434d216ceabb9a99f1c763da8d9f9bdf2128ab2a743fc23
6
+ metadata.gz: e11526748776eeb71864eb443c1cc16526b4c5e233d9488a9a207839270f8b4985a36de51942ed33cf5c6cec72ff5a236de8a28ff1eb46be6471b28032cb1514
7
+ data.tar.gz: 349cb861579f0c721068dc77f18113c71468f961c91dc3c887d49fc1e190874212c2879b26531a8836b18c6058caf9f0ae97e76a45660eb5982ccdc3a78c7cfd
@@ -53,12 +53,9 @@ module ActiveRecord
53
53
 
54
54
  break if batch.size < batch_size
55
55
 
56
- # some relations don't have arel_attribute, need to figure that out
57
- if respond_to?(:arel_attribute)
58
- batch_relation = relation.where(arel_attribute(primary_key).gt(primary_key_offset))
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
@@ -1,3 +1,3 @@
1
1
  module PluckEach
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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.2
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-03 00:00:00.000000000 Z
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.2.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