pluck_in_batches 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2100a773ebc1bbfd8f51101298b35ddc7152dfac6810a443d89d78236de21b2
4
- data.tar.gz: 0d4e03fb76a2d33822ab4a78ee3d43d464f4183e8485afba7a34e6ec276c2a48
3
+ metadata.gz: 7c30844758feb52e696cbde2155d47204b537201975ec2a7857db5400ca982c9
4
+ data.tar.gz: 69c73ac8249b95a2b9d8e4542396ee7969be7d28aa3e2277b06f5ed652eedc87
5
5
  SHA512:
6
- metadata.gz: f4fb12334c280f32979eb3a3c4cac9670c39c29e4811f4e0f5bcf35951b804bf0bb2ce99604acd2b8188766436e4cbfe774d49b6a68f70c731de5d745e30c25b
7
- data.tar.gz: 91c216a345b096137287ccec020f9a1942777d873476751e8f31b9b0f3c3dd8185c6997d49c3e03d72239b77af96f41b13f9385cf44d87770be91312b5b76273
6
+ metadata.gz: 7e49e5929fefd29e092c0dc5da7f051fd735dd2175a347dfa0a34af274c105b3dd5c4897f90b350ad2ac982b260f4cfbe64d2504878f5f554036bb7466210579
7
+ data.tar.gz: a1ba0c9f0a426c0fd6cd73985af955cad50dbca4c7777049b94cbf85f655721edffeb13dc4bc71d8c8bc78e357ff22b620b96b7718a64c59a8fb091e3029164d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.3.0 (2024-11-03)
4
+
5
+ - Support plucking custom Arel columns
6
+
7
+ ```ruby
8
+ User.pluck_in_batches(:id, Arel.sql("json_extract(users.metadata, '$.rank')"))
9
+ ```
10
+
3
11
  ## 0.2.0 (2023-07-24)
4
12
 
5
13
  - Support specifying per cursor column ordering when batching
data/README.md CHANGED
@@ -91,6 +91,11 @@ User.pluck_in_batches(:name, :email).with_index do |group, index|
91
91
  jobs = group.map { |name, email| PartyReminderJob.new(name, email) }
92
92
  ActiveJob.perform_all_later(jobs)
93
93
  end
94
+
95
+ # Custom arel column
96
+ User.pluck_in_batches(:id, Arel.sql("json_extract(users.metadata, '$.rank')")).with_index do |group, index|
97
+ # ...
98
+ end
94
99
  ```
95
100
 
96
101
  Both methods support the following configuration options:
@@ -35,7 +35,14 @@ module PluckInBatches
35
35
  raise ArgumentError, ":order must be :asc or :desc or an array consisting of :asc or :desc, got #{order.inspect}"
36
36
  end
37
37
 
38
- pluck_columns = columns.map(&:to_s)
38
+ pluck_columns = columns.map do |column|
39
+ if Arel.arel_node?(column)
40
+ column
41
+ else
42
+ column.to_s
43
+ end
44
+ end
45
+
39
46
  cursor_columns = Array(cursor_column).map(&:to_s)
40
47
  cursor_column_indexes = cursor_column_indexes(pluck_columns, cursor_columns)
41
48
  missing_cursor_columns = cursor_column_indexes.count(&:nil?)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PluckInBatches
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluck_in_batches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2024-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubygems_version: 3.4.6
63
+ rubygems_version: 3.4.19
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: A faster alternative to the custom use of `in_batches` with `pluck`.