Skip to content

Commit 81437bc

Browse files
committed
Replaces IOD::Identity with AR::Type::Value (afair#44)
This fix for a new method of building column types got lost during merging.
1 parent 44e9d69 commit 81437bc

File tree

5 files changed

+40
-25
lines changed

5 files changed

+40
-25
lines changed

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ GEM
2121
concurrent-ruby (1.1.5)
2222
i18n (1.6.0)
2323
concurrent-ruby (~> 1.0)
24+
irb (1.0.0)
2425
minitest (5.12.0)
2526
pg (1.1.4)
2627
rake (13.0.0)
@@ -33,6 +34,7 @@ PLATFORMS
3334
ruby
3435

3536
DEPENDENCIES
37+
irb
3638
minitest
3739
pg
3840
postgresql_cursor!

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ end
1111

1212
desc "Open and IRB Console with the gem and test-app loaded"
1313
task :console do
14-
sh "bundle exec irb -Ilib -I . -r postgresql_cursor -r test-app/app"
14+
sh "bundle exec irb -Ilib -I . -r pg -r postgresql_cursor -r test-app/app"
1515
#require 'irb'
1616
#ARGV.clear
1717
#IRB.start

lib/postgresql_cursor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'postgresql_cursor/version'
4+
require 'active_support'
45

56
ActiveSupport.on_load :active_record do
67
require 'postgresql_cursor/cursor'

lib/postgresql_cursor/cursor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ def column_types
232232
fields.each_with_index do |fname, i|
233233
ftype = @result.ftype i
234234
fmod = @result.fmod i
235-
types[fname] = @connection.get_type_map.fetch(ftype, fmod) { |oid, mod|
235+
types[fname] = @connection.get_type_map.fetch(ftype, fmod) do |oid, mod|
236236
warn "unknown OID: #{fname}(#{oid}) (#{sql})"
237237
if ::ActiveRecord::VERSION::MAJOR <= 4
238-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Identity.new
238+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Identity.new
239239
else
240-
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Identity.new
240+
::ActiveRecord::Type::Value.new
241241
end
242-
}
242+
end
243243
end
244244

245245
@column_types = types

postgresql_cursor.gemspec

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
1-
# coding: utf-8
2-
lib = File.expand_path('../lib', __FILE__)
1+
# frozen_string_literal: true
2+
3+
lib = File.expand_path('lib', __dir__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45
require 'postgresql_cursor/version'
56

67
Gem::Specification.new do |spec|
7-
spec.name = "postgresql_cursor"
8+
spec.name = 'postgresql_cursor'
89
spec.version = PostgresqlCursor::VERSION
9-
spec.authors = ["Allen Fair"]
10-
spec.email = ["[email protected]"]
11-
spec.summary = "ActiveRecord PostgreSQL Adapter extension for using a cursor to return a large result set"
12-
spec.description = "PostgreSQL Cursor is an extension to the ActiveRecord PostgreSQLAdapter for very large result sets. It provides a cursor open/fetch/close interface to access data without loading all rows into memory, and instead loads the result rows in \"chunks\" (default of 1_000 rows), buffers them, and returns the rows one at a time."
13-
spec.homepage = "http://github.com/afair/postgresql_cursor"
14-
spec.license = "MIT"
10+
spec.authors = ['Allen Fair']
11+
spec.email = ['[email protected]']
12+
spec.summary = <<-SUMMARY
13+
ActiveRecord PostgreSQL Adapter extension for using a cursor to return a
14+
large result set
15+
SUMMARY
16+
spec.description = <<-DESCRIPTION
17+
PostgreSQL Cursor is an extension to the ActiveRecord PostgreSQLAdapter for
18+
very large result sets. It provides a cursor open/fetch/close interface to
19+
access data without loading all rows into memory, and instead loads the result
20+
rows in 'chunks' (default of 1_000 rows), buffers them, and returns the rows
21+
one at a time.
22+
DESCRIPTION
23+
spec.homepage = 'http://github.com/afair/postgresql_cursor'
24+
spec.license = 'MIT'
1525

1626
spec.files = `git ls-files -z`.split("\x0")
1727
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
1828
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19-
spec.require_paths = ["lib"]
29+
spec.require_paths = ['lib']
30+
31+
# Remove this for jruby which should use 'activerecord-jdbcpostgresql-adapter'
32+
# spec.add_dependency 'pg'
2033

21-
#spec.add_dependency "pg" # Remove this for jruby, which should specify 'activerecord-jdbcpostgresql-adapter'
22-
spec.add_dependency "activerecord", ">= 3.1.0"
23-
#spec.add_dependency "activerecord", "~> 3.1.0"
24-
# Tests don't run on 4.0.0 since AR/AS have an older version of minitest as a run-time dependency(!) than our tests support
25-
#spec.add_dependency "activerecord", "~> 4.0.0";# spec.add_dependency "minitest", "~> 4.2.0"
26-
#spec.add_dependency "activerecord", "~> 4.1.0"
27-
#spec.add_dependency "activerecord", "~> 5.0.0.beta2"
34+
spec.add_dependency 'activerecord', '>= 3.1.0'
35+
# spec.add_dependency 'activerecord', '~> 3.1.0'
36+
# spec.add_dependency 'activerecord', '~> 4.1.0'
37+
# spec.add_dependency 'activerecord', '~> 5.0.0'
38+
# spec.add_dependency 'activerecord', '~> 6.0.0'
2839

29-
spec.add_development_dependency "pg"
30-
spec.add_development_dependency "rake"
31-
spec.add_development_dependency "minitest"
40+
spec.add_development_dependency 'irb'
41+
spec.add_development_dependency 'minitest'
42+
spec.add_development_dependency 'pg'
43+
spec.add_development_dependency 'rake'
3244
end

0 commit comments

Comments
 (0)