activerecord-postgresql-cursors 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +71 -0
- data/.rubocop-minitest.yml +240 -0
- data/.rubocop.yml +5683 -0
- data/.rubocop_todo.yml +26 -0
- data/FUNDING.yml +2 -0
- data/Gemfile +13 -16
- data/Guardfile +8 -10
- data/MIT-LICENSE +1 -2
- data/{README.rdoc → README.md} +12 -10
- data/Rakefile +5 -6
- data/activerecord-postgresql-cursors.gemspec +15 -15
- data/lib/active_record/postgresql_cursors/cursors.rb +4 -8
- data/lib/active_record/postgresql_cursors/version.rb +2 -2
- data/lib/activerecord-postgresql-cursors.rb +40 -34
- data/sonar-project.properties +17 -0
- data/test/ci/github/database.yml +10 -0
- data/test/{cursor_tests.rb → cursor_test.rb} +16 -11
- data/test/test_helper.rb +20 -25
- metadata +22 -19
- data/.travis.yml +0 -18
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2024-08-06 02:41:08 UTC using RuboCop version 1.65.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/activerecord-postgresql-cursors.rb'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
17
|
+
Metrics/PerceivedComplexity:
|
18
|
+
Max: 9
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
22
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
23
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
24
|
+
Naming/FileName:
|
25
|
+
Exclude:
|
26
|
+
- 'lib/activerecord-postgresql-cursors.rb'
|
data/FUNDING.yml
ADDED
data/Gemfile
CHANGED
@@ -1,21 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem "guard-minitest"
|
16
|
-
gem "simplecov"
|
17
|
-
|
18
|
-
if File.exists?('Gemfile.local')
|
19
|
-
instance_eval File.read('Gemfile.local')
|
20
|
-
end
|
7
|
+
gem 'guard'
|
8
|
+
gem 'guard-minitest'
|
9
|
+
gem 'minitest'
|
10
|
+
gem 'minitest-reporters'
|
11
|
+
gem 'pg'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rubocop', require: false
|
14
|
+
gem 'rubocop-minitest', require: false
|
15
|
+
gem 'simplecov', require: false
|
16
|
+
gem 'simplecov_json_formatter', require: false
|
21
17
|
|
18
|
+
instance_eval File.read('Gemfile.local') if File.exist?('Gemfile.local')
|
data/Guardfile
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
guard 'minitest', :
|
3
|
-
watch(%r
|
3
|
+
guard 'minitest', test_folders: 'test', test_file_patterns: '*_tests.rb' do
|
4
|
+
watch(%r{^test/(.+)_tests\.rb})
|
4
5
|
|
5
|
-
watch(%r
|
6
|
-
|
6
|
+
watch(%r{^lib/(.*)([^/]+)\.rb}) do |_m|
|
7
|
+
'test/cursor_tests.rb'
|
7
8
|
end
|
8
9
|
|
9
|
-
watch(%r
|
10
|
-
|
10
|
+
watch(%r{^test/test_helper\.rb}) do
|
11
|
+
'test'
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
if File.
|
15
|
-
instance_eval File.read('Guardfile.local')
|
16
|
-
end
|
17
|
-
|
15
|
+
instance_eval File.read('Guardfile.local') if File.exist?('Guardfile.local')
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008-
|
1
|
+
Copyright (c) 2008-2024 J Smith <dark.panda@gmail.com>
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person
|
4
4
|
obtaining a copy of this software and associated documentation
|
@@ -20,4 +20,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
20
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
21
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
22
|
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ActiveRecord PostgreSQL Cursors
|
2
2
|
|
3
3
|
This extension allows you to loop through record sets using cursors in an
|
4
4
|
Enumerable fashion. This allows you to cut down memory usage by only pulling
|
@@ -9,21 +9,23 @@ To use a cursor, just change the first parameter to an
|
|
9
9
|
ActiveRecord::Base.find to :cursor instead of :first or :all or
|
10
10
|
whatever or use the ActiveRecord::Base.cursor method directly.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
```ruby
|
13
|
+
MyModel.find(:cursor, :conditions => 'some_column = true').each do |r|
|
14
|
+
puts r.inspect
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
MyModel.find(:cursor).collect { |r| r.foo / PI }.avg
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
MyModel.cursor.each do |r|
|
20
|
+
puts r.inspect
|
21
|
+
end
|
22
|
+
```
|
21
23
|
|
22
24
|
All ActiveRecord::Base.find options are available and should work as-is.
|
23
25
|
As a bonus, the PostgreSQLCursor object returned includes Enumerable,
|
24
26
|
so you can iterate to your heart's content.
|
25
27
|
|
26
|
-
This extension should work with Rails
|
28
|
+
This extension should work with Rails 6.1+. For older versions of Rails, try
|
27
29
|
out older versions of the gem.
|
28
30
|
|
29
31
|
At the moment, this is a non-scrollable cursor -- it will only fetch
|
@@ -51,7 +53,7 @@ created and the time it is executed. In these cases, it may be wise to wrap
|
|
51
53
|
your use or cursors in your own transaction to ensure that changes made to
|
52
54
|
the underlying data don't interfere with your cursor's visibility.
|
53
55
|
|
54
|
-
|
56
|
+
## License
|
55
57
|
|
56
58
|
This gem is licensed under an MIT-style license. See the +MIT-LICENSE+ file for
|
57
59
|
details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
# -*- ruby -*-
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'rubygems'
|
5
4
|
require 'rubygems/package_task'
|
@@ -7,24 +6,24 @@ require 'rake/testtask'
|
|
7
6
|
require 'rdoc/task'
|
8
7
|
require 'bundler/gem_tasks'
|
9
8
|
|
10
|
-
|
9
|
+
$LOAD_PATH.push File.expand_path(File.dirname(__FILE__), 'lib')
|
11
10
|
|
12
11
|
version = ActiveRecord::PostgreSQLCursors::VERSION
|
13
12
|
|
14
13
|
desc 'Test PostgreSQL extensions'
|
15
14
|
Rake::TestTask.new(:test) do |t|
|
16
15
|
t.libs << "#{File.dirname(__FILE__)}/test"
|
17
|
-
t.test_files = FileList['test/**/*
|
16
|
+
t.test_files = FileList['test/**/*_test.rb']
|
18
17
|
t.verbose = !!ENV['VERBOSE_TESTS']
|
19
18
|
t.warning = !!ENV['WARNINGS']
|
20
19
|
end
|
21
20
|
|
22
|
-
task :
|
21
|
+
task default: :test
|
23
22
|
|
24
23
|
desc 'Build docs'
|
25
24
|
Rake::RDocTask.new do |t|
|
26
25
|
t.title = "ActiveRecord PostgreSQL Cursors #{version}"
|
27
|
-
t.main = 'README.
|
26
|
+
t.main = 'README.md'
|
28
27
|
t.rdoc_dir = 'doc'
|
29
28
|
t.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'lib/**/*.rb')
|
30
29
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('lib/active_record/postgresql_cursors/version', __dir__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'activerecord-postgresql-cursors'
|
7
7
|
s.version = ActiveRecord::PostgreSQLCursors::VERSION
|
8
8
|
|
9
|
-
s.required_rubygems_version = Gem::Requirement.new(
|
10
|
-
s.
|
11
|
-
s.
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
10
|
+
s.required_ruby_version = '>= 3.0'
|
11
|
+
s.authors = ['J Smith']
|
12
|
+
s.description = 'Provides some support for PostgreSQL cursors in ActiveRecord.'
|
12
13
|
s.summary = s.description
|
13
|
-
s.email =
|
14
|
-
s.license =
|
14
|
+
s.email = 'dark.panda@gmail.com'
|
15
|
+
s.license = 'MIT'
|
15
16
|
s.extra_rdoc_files = [
|
16
|
-
|
17
|
+
'README.md'
|
17
18
|
]
|
18
|
-
s.files = `git ls-files`.split(
|
19
|
+
s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
19
20
|
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
20
|
-
s.
|
21
|
-
s.
|
22
|
-
s.require_paths = ["lib"]
|
21
|
+
s.homepage = 'http://github.com/dark-panda/activerecord-postgresql-cursors'
|
22
|
+
s.require_paths = ['lib']
|
23
23
|
|
24
|
-
s.add_dependency(
|
24
|
+
s.add_dependency('activerecord', ['>= 6.1'])
|
25
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
25
26
|
end
|
26
|
-
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module ActiveRecord
|
3
4
|
module CursorExtensions
|
@@ -28,19 +29,14 @@ module ActiveRecord
|
|
28
29
|
# ActiveRecord::Base#find_every method, except it returns a
|
29
30
|
# PostgreSQLCursor object that can be used to loop through records.
|
30
31
|
def find_cursor(cursor_name, options)
|
31
|
-
unless connection.is_a? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
32
|
-
raise CursorsNotSupported, "#{connection.class} doesn't support cursors"
|
33
|
-
end
|
32
|
+
raise CursorsNotSupported, "#{connection.class} doesn't support cursors" unless connection.is_a? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
34
33
|
|
35
34
|
relation = merge(options.slice(:readonly, :references, :order, :limit, :joins, :group, :having, :offset, :select, :uniq))
|
36
35
|
including = (relation.eager_load_values + relation.includes_values).uniq
|
37
36
|
|
38
37
|
if including.present?
|
39
|
-
join_dependency = construct_join_dependency(joins_values)
|
40
|
-
|
41
|
-
aliases = join_dependency.aliases
|
42
|
-
join_relation = select(aliases.columns)
|
43
|
-
join_relation = apply_join_dependency(join_relation, join_dependency)
|
38
|
+
join_dependency = construct_join_dependency(joins_values, nil)
|
39
|
+
join_relation = apply_join_dependency
|
44
40
|
|
45
41
|
ActiveRecord::PostgreSQLCursor.new(self, cursor_name, join_relation, join_dependency)
|
46
42
|
else
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module ActiveRecord
|
3
4
|
# Exception raised when database cursors aren't supported, which they
|
@@ -17,9 +18,7 @@ module ActiveRecord
|
|
17
18
|
@relation = relation
|
18
19
|
@join_dependency = join_dependency
|
19
20
|
|
20
|
-
@cursor_name = if cursor_name
|
21
|
-
@model.connection.quote_table_name(cursor_name.gsub(/"/, '\"'))
|
22
|
-
end
|
21
|
+
@cursor_name = (@model.connection.quote_table_name(cursor_name.gsub('"', '\"')) if cursor_name)
|
23
22
|
|
24
23
|
@query = model.connection.unprepared_statement do
|
25
24
|
relation.to_sql
|
@@ -34,38 +33,43 @@ module ActiveRecord
|
|
34
33
|
# record as a parameter.
|
35
34
|
def each
|
36
35
|
@model.transaction do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
last_id = current_id
|
51
|
-
else
|
52
|
-
yield @join_dependency.instantiate(rows, @join_dependency.aliases).first
|
53
|
-
rows = [ row ]
|
54
|
-
end
|
36
|
+
declare_cursor
|
37
|
+
|
38
|
+
if @join_dependency
|
39
|
+
rows = []
|
40
|
+
last_id = nil
|
41
|
+
|
42
|
+
until (row = fetch_forward).empty?
|
43
|
+
instantiated_row = @join_dependency.instantiate(row, true).first
|
44
|
+
current_id = instantiated_row[@join_dependency.send(:join_root).primary_key]
|
45
|
+
last_id ||= current_id
|
46
|
+
|
47
|
+
if last_id == current_id
|
48
|
+
rows << row.first.values
|
55
49
|
last_id = current_id
|
56
|
-
|
50
|
+
else
|
51
|
+
result_set = ActiveRecord::Result.new(row.columns, rows, row.column_types)
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
else
|
62
|
-
while row = fetch_forward
|
63
|
-
yield @model.instantiate(row)
|
53
|
+
yield @join_dependency.instantiate(result_set, true).first
|
54
|
+
|
55
|
+
rows = [row.first.values]
|
64
56
|
end
|
57
|
+
|
58
|
+
last_id = current_id
|
59
|
+
end
|
60
|
+
|
61
|
+
unless rows.empty?
|
62
|
+
result_set = ActiveRecord::Result.new(row.columns, rows, row.column_types)
|
63
|
+
|
64
|
+
yield @join_dependency.instantiate(result_set, true).first
|
65
|
+
end
|
66
|
+
else
|
67
|
+
until (row = fetch_forward).empty?
|
68
|
+
yield @model.instantiate(row.first)
|
65
69
|
end
|
66
|
-
ensure
|
67
|
-
close_cursor
|
68
70
|
end
|
71
|
+
ensure
|
72
|
+
close_cursor
|
69
73
|
end
|
70
74
|
nil
|
71
75
|
end
|
@@ -76,15 +80,17 @@ module ActiveRecord
|
|
76
80
|
@cursor_name ||= "cursor_#{(rand * 1_000_000).ceil}"
|
77
81
|
end
|
78
82
|
|
79
|
-
def fetch_forward
|
80
|
-
@relation.
|
83
|
+
def fetch_forward # :nodoc:
|
84
|
+
@relation.uncached do
|
85
|
+
@relation.connection.select_all(%{FETCH FORWARD FROM #{cursor_name}})
|
86
|
+
end
|
81
87
|
end
|
82
88
|
|
83
|
-
def declare_cursor
|
89
|
+
def declare_cursor # :nodoc:
|
84
90
|
@model.connection.execute(%{DECLARE #{cursor_name} CURSOR FOR #{@query}})
|
85
91
|
end
|
86
92
|
|
87
|
-
def close_cursor
|
93
|
+
def close_cursor # :nodoc:
|
88
94
|
@model.connection.execute(%{CLOSE #{cursor_name}})
|
89
95
|
end
|
90
96
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
sonar.projectKey=dark-panda_activerecord-postgresql-cursors
|
2
|
+
sonar.organization=dark-panda
|
3
|
+
|
4
|
+
# This is the name and version displayed in the SonarCloud UI.
|
5
|
+
sonar.projectName=activerecord-postgresql-cursors
|
6
|
+
sonar.projectVersion=1.0
|
7
|
+
|
8
|
+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
|
9
|
+
sonar.sources=lib, test
|
10
|
+
sonar.coverage.exclusions=test
|
11
|
+
|
12
|
+
# Encoding of the source code. Default is default system encoding
|
13
|
+
sonar.sourceEncoding=UTF-8
|
14
|
+
|
15
|
+
# Additional reports
|
16
|
+
sonar.ruby.rubocop.reportPaths=rubocop-report.json
|
17
|
+
sonar.ruby.coverage.reportPaths=coverage/coverage.json
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'test_helper'
|
3
4
|
|
@@ -7,7 +8,7 @@ class PostgreSQLCursorTests < Minitest::Test
|
|
7
8
|
def test_cursor_scoped
|
8
9
|
cursor = Foo.cursor(order: 'id')
|
9
10
|
|
10
|
-
|
11
|
+
assert_kind_of(ActiveRecord::PostgreSQLCursor, cursor)
|
11
12
|
|
12
13
|
assert_equal(%w{ one two three four five }, cursor.collect(&:name))
|
13
14
|
end
|
@@ -17,6 +18,7 @@ class PostgreSQLCursorTests < Minitest::Test
|
|
17
18
|
|
18
19
|
cursor.each do |row|
|
19
20
|
row.name = "#{row.name}_updated"
|
21
|
+
|
20
22
|
assert(row.save)
|
21
23
|
end
|
22
24
|
|
@@ -27,9 +29,9 @@ class PostgreSQLCursorTests < Minitest::Test
|
|
27
29
|
cursor = Foo.cursor(order: 'id')
|
28
30
|
|
29
31
|
cursor.each do |row|
|
30
|
-
|
32
|
+
assert_kind_of(Foo, row)
|
31
33
|
row.bars.each do |bar|
|
32
|
-
|
34
|
+
assert_kind_of(Bar, bar)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -38,9 +40,9 @@ class PostgreSQLCursorTests < Minitest::Test
|
|
38
40
|
cursor = Foo.cursor(order: 'foos.id', include: :bars)
|
39
41
|
|
40
42
|
cursor.each do |row|
|
41
|
-
|
43
|
+
assert_kind_of(Foo, row)
|
42
44
|
row.bars.each do |bar|
|
43
|
-
|
45
|
+
assert_kind_of(Bar, bar)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -50,36 +52,39 @@ class PostgreSQLCursorTests < Minitest::Test
|
|
50
52
|
|
51
53
|
cursor.each do |row|
|
52
54
|
bars_cursor = row.bars.cursor
|
53
|
-
|
55
|
+
|
56
|
+
assert_kind_of(ActiveRecord::PostgreSQLCursor, bars_cursor)
|
54
57
|
|
55
58
|
bars_cursor.each do |bar|
|
56
|
-
|
59
|
+
assert_kind_of(Bar, bar)
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
61
64
|
def test_as_relation
|
62
65
|
cursor = Foo.order('foos.id').where('foos.id >= 3').cursor
|
66
|
+
|
63
67
|
assert_equal(3, cursor.to_a.length)
|
64
68
|
|
65
69
|
cursor.each do |row|
|
66
|
-
|
70
|
+
assert_kind_of(Foo, row)
|
67
71
|
assert_equal(2, row.bars.length)
|
68
72
|
row.bars.each do |bar|
|
69
|
-
|
73
|
+
assert_kind_of(Bar, bar)
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
74
78
|
def test_as_relation_with_associations
|
75
79
|
cursor = Foo.includes(:bars).order('foos.id').where('foos.id >= 3').cursor
|
80
|
+
|
76
81
|
assert_equal(3, cursor.to_a.length)
|
77
82
|
|
78
83
|
cursor.each do |row|
|
79
|
-
|
84
|
+
assert_kind_of(Foo, row)
|
80
85
|
assert_equal(2, row.bars.length)
|
81
86
|
row.bars.each do |bar|
|
82
|
-
|
87
|
+
assert_kind_of(Bar, bar)
|
83
88
|
end
|
84
89
|
end
|
85
90
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'simplecov'
|
3
4
|
|
@@ -17,29 +18,15 @@ require 'minitest/reporters'
|
|
17
18
|
require File.join(File.dirname(__FILE__), *%w{ .. lib activerecord-postgresql-cursors })
|
18
19
|
|
19
20
|
ActiveRecord::Base.logger = Logger.new('debug.log') if ENV['ENABLE_LOGGER']
|
20
|
-
ActiveRecord::Base.configurations = {
|
21
|
-
'arunit' => {}
|
22
|
-
}
|
23
21
|
|
24
|
-
|
25
|
-
database.yml
|
26
|
-
local_database.yml
|
27
|
-
}.each do |file|
|
28
|
-
file = File.join('test', file)
|
22
|
+
configurations = {}
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
if configuration['arunit']
|
35
|
-
ActiveRecord::Base.configurations['arunit'] = configuration['arunit']
|
36
|
-
end
|
37
|
-
|
38
|
-
if defined?(JRUBY_VERSION) && configuration['jdbc']
|
39
|
-
ActiveRecord::Base.configurations['arunit'].merge!(configuration['jdbc'])
|
40
|
-
end
|
41
|
-
end
|
24
|
+
file = File.join('test', 'database.yml')
|
25
|
+
configuration = YAML.safe_load_file(file)
|
26
|
+
configurations['arunit'] = configuration['arunit'] if configuration['arunit']
|
27
|
+
configurations['arunit'].merge!(configuration['jdbc']) if defined?(JRUBY_VERSION) && configuration['jdbc']
|
42
28
|
|
29
|
+
ActiveRecord::Base.configurations = configurations
|
43
30
|
ActiveRecord::Base.establish_connection :arunit
|
44
31
|
ARBC = ActiveRecord::Base.connection
|
45
32
|
|
@@ -48,9 +35,7 @@ puts "Testing against ActiveRecord #{Gem.loaded_specs['activerecord'].version}"
|
|
48
35
|
|
49
36
|
postgresql_version = ARBC.select_rows('SELECT version()').flatten.to_s
|
50
37
|
|
51
|
-
if postgresql_version
|
52
|
-
puts "PostgreSQL info from version(): #{postgresql_version}"
|
53
|
-
end
|
38
|
+
puts "PostgreSQL info from version(): #{postgresql_version}" if postgresql_version
|
54
39
|
|
55
40
|
unless ARBC.data_source_exists?('foos')
|
56
41
|
ActiveRecord::Migration.create_table(:foos) do |t|
|
@@ -86,10 +71,20 @@ module PostgreSQLCursorTestHelper
|
|
86
71
|
|
87
72
|
%w{ one two three four five }.each_with_index do |name, i|
|
88
73
|
foo = Foo.new(name: name)
|
89
|
-
foo.bar_ids = [
|
74
|
+
foo.bar_ids = [i + 1, i + 6]
|
90
75
|
foo.save
|
91
76
|
end
|
92
77
|
end
|
93
78
|
end
|
94
79
|
|
95
|
-
Minitest::Reporters.use!(
|
80
|
+
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
|
81
|
+
|
82
|
+
if ENV['CI']
|
83
|
+
require 'simplecov_json_formatter'
|
84
|
+
|
85
|
+
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
|
86
|
+
elsif ENV.fetch('COVERAGE', nil) == 'console'
|
87
|
+
require_relative 'support/rspec_console'
|
88
|
+
|
89
|
+
SimpleCov.formatter = SecuricyApp::SimpleCov::Formatter::RSpecConsole
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-postgresql-cursors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J Smith
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,40 +16,47 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.1'
|
27
27
|
description: Provides some support for PostgreSQL cursors in ActiveRecord.
|
28
28
|
email: dark.panda@gmail.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files:
|
32
|
-
- README.
|
32
|
+
- README.md
|
33
33
|
files:
|
34
|
+
- ".github/workflows/main.yml"
|
34
35
|
- ".gitignore"
|
35
|
-
- ".
|
36
|
+
- ".rubocop-minitest.yml"
|
37
|
+
- ".rubocop.yml"
|
38
|
+
- ".rubocop_todo.yml"
|
39
|
+
- FUNDING.yml
|
36
40
|
- Gemfile
|
37
41
|
- Guardfile
|
38
42
|
- MIT-LICENSE
|
39
|
-
- README.
|
43
|
+
- README.md
|
40
44
|
- Rakefile
|
41
45
|
- activerecord-postgresql-cursors.gemspec
|
42
46
|
- lib/active_record/postgresql_cursors/cursors.rb
|
43
47
|
- lib/active_record/postgresql_cursors/version.rb
|
44
48
|
- lib/activerecord-postgresql-cursors.rb
|
45
|
-
-
|
49
|
+
- sonar-project.properties
|
50
|
+
- test/ci/github/database.yml
|
51
|
+
- test/cursor_test.rb
|
46
52
|
- test/database.yml
|
47
53
|
- test/test_helper.rb
|
48
54
|
homepage: http://github.com/dark-panda/activerecord-postgresql-cursors
|
49
55
|
licenses:
|
50
56
|
- MIT
|
51
|
-
metadata:
|
52
|
-
|
57
|
+
metadata:
|
58
|
+
rubygems_mfa_required: 'true'
|
59
|
+
post_install_message:
|
53
60
|
rdoc_options: []
|
54
61
|
require_paths:
|
55
62
|
- lib
|
@@ -57,19 +64,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
64
|
requirements:
|
58
65
|
- - ">="
|
59
66
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
67
|
+
version: '3.0'
|
61
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
69
|
requirements:
|
63
70
|
- - ">="
|
64
71
|
- !ruby/object:Gem::Version
|
65
72
|
version: '0'
|
66
73
|
requirements: []
|
67
|
-
|
68
|
-
|
69
|
-
signing_key:
|
74
|
+
rubygems_version: 3.5.11
|
75
|
+
signing_key:
|
70
76
|
specification_version: 4
|
71
77
|
summary: Provides some support for PostgreSQL cursors in ActiveRecord.
|
72
|
-
test_files:
|
73
|
-
- test/cursor_tests.rb
|
74
|
-
- test/database.yml
|
75
|
-
- test/test_helper.rb
|
78
|
+
test_files: []
|