Skip to content

Commit

Permalink
Merge branch 'master' into OhSixTwo_without_Identity
Browse files Browse the repository at this point in the history
  • Loading branch information
afair committed Sep 27, 2019
2 parents 6a407fd + 024d450 commit ed5b2cb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/postgresql_cursor/cursor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'active_record/connection_adapters/postgresql/oid'

################################################################################
# PostgreSQLCursor: library class provides postgresql cursor for large result
# set processing. Requires ActiveRecord, but can be adapted to other DBI/ORM libraries.
Expand All @@ -20,13 +18,6 @@
# ActiveRecordModel.each_instance_by_sql("select ...") { |model| ... }
#


if ::ActiveRecord::VERSION::MAJOR <= 4
OID = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID
else
OID = ActiveRecord::ConnectionAdapters::PostgreSQL::OID
end

module PostgreSQLCursor
class Cursor
include Enumerable
Expand Down Expand Up @@ -240,7 +231,11 @@ def column_types
fmod = @result.fmod i
types[fname] = @connection.get_type_map.fetch(ftype, fmod) { |oid, mod|
warn "unknown OID: #{fname}(#{oid}) (#{sql})"
::ActiveRecord::Type::Value.new
if ::ActiveRecord::VERSION::MAJOR <= 4
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Identity.new
else
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Identity.new
end
}
end

Expand Down

0 comments on commit ed5b2cb

Please sign in to comment.