File tree Expand file tree Collapse file tree 6 files changed +26
-17
lines changed Expand file tree Collapse file tree 6 files changed +26
-17
lines changed Original file line number Diff line number Diff line change 1
1
PATH
2
2
remote: .
3
3
specs:
4
- postgresql_cursor (0.6.2 )
4
+ postgresql_cursor (0.6.3 )
5
5
activerecord (>= 3.1.0 )
6
6
7
7
GEM
8
8
remote: https://rubygems.org/
9
9
specs:
10
- activemodel (5.2.1 )
11
- activesupport (= 5.2.1 )
12
- activerecord (5.2.1 )
13
- activemodel (= 5.2.1 )
14
- activesupport (= 5.2.1 )
15
- arel (>= 9.0 )
16
- activesupport (5.2.1 )
10
+ activemodel (6.0.0 )
11
+ activesupport (= 6.0.0 )
12
+ activerecord (6.0.0 )
13
+ activemodel (= 6.0.0 )
14
+ activesupport (= 6.0.0 )
15
+ activesupport (6.0.0 )
17
16
concurrent-ruby (~> 1.0 , >= 1.0.2 )
18
17
i18n (>= 0.7 , < 2 )
19
18
minitest (~> 5.1 )
20
19
tzinfo (~> 1.1 )
21
- arel ( 9.0.0 )
22
- concurrent-ruby (1.0 .5 )
23
- i18n (1.1 .0 )
20
+ zeitwerk ( ~> 2.1 , >= 2.1.8 )
21
+ concurrent-ruby (1.1 .5 )
22
+ i18n (1.6 .0 )
24
23
concurrent-ruby (~> 1.0 )
25
- minitest (5.11.3 )
26
- pg (1.0.0 )
27
- rake (12.3.1 )
24
+ minitest (5.12.0 )
25
+ pg (1.1.4 )
26
+ rake (13.0.0 )
28
27
thread_safe (0.3.6 )
29
28
tzinfo (1.2.5 )
30
29
thread_safe (~> 0.1 )
30
+ zeitwerk (2.1.10 )
31
31
32
32
PLATFORMS
33
33
ruby
@@ -39,4 +39,4 @@ DEPENDENCIES
39
39
rake
40
40
41
41
BUNDLED WITH
42
- 1.16 .3
42
+ 1.17 .3
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ All these methods take an options hash to control things more:
67
67
This library uses 1.0 (Optimize for 100% of the result set)
68
68
Do not override this value unless you understand it.
69
69
with_hold:boolean Keep the cursor "open" even after a commit.
70
+ cursor_name:string Give your cursor a name.
70
71
71
72
Notes:
72
73
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
1
3
require 'postgresql_cursor/version'
2
4
3
5
ActiveSupport . on_load :active_record do
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
1
3
# Defines extension to ActiveRecord/AREL to use this library
2
4
module PostgreSQLCursor
3
5
module ActiveRecord
@@ -12,6 +14,7 @@ module CursorIterators
12
14
# block_size: 1..n - The number of rows to fetch per db block fetch
13
15
# while: value - Exits loop when block does not return this value.
14
16
# until: value - Exits loop when block returns this value.
17
+ # cursor_name: string - Allows you to name your cursor.
15
18
#
16
19
# Example:
17
20
# Post.where(user_id:123).each_row { |hash| Post.process(hash) }
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
1
3
################################################################################
2
4
# PostgreSQLCursor: library class provides postgresql cursor for large result
3
5
# set processing. Requires ActiveRecord, but can be adapted to other DBI/ORM libraries.
10
12
# while: value - Exits loop when block does not return this value.
11
13
# until: value - Exits loop when block returns this value.
12
14
# with_hold: boolean - Allows the query to remain open across commit points.
15
+ # cursor_name: string - Allows you to name your cursor.
13
16
#
14
17
# Exmaples:
15
18
# PostgreSQLCursor::Cursor.new("select ...").each { |hash| ... }
@@ -245,7 +248,7 @@ def column_types
245
248
# Public: Opens (actually, "declares") the cursor. Call this before fetching
246
249
def open
247
250
set_cursor_tuple_fraction
248
- @cursor = SecureRandom . uuid . gsub ( "-" , "" )
251
+ @cursor = @options [ :cursor_name ] || SecureRandom . uuid . gsub ( "-" , "" )
249
252
hold = @options [ :with_hold ] ? 'with hold ' : ''
250
253
@result = @connection . execute ( "declare cursor_#{ @cursor } no scroll cursor #{ hold } for #{ @sql } " )
251
254
@block = [ ]
Original file line number Diff line number Diff line change 1
1
module PostgresqlCursor
2
- VERSION = "0.6.2.1 "
2
+ VERSION = "0.6.3 "
3
3
end
You can’t perform that action at this time.
0 commit comments