Skip to content

Commit

Permalink
Revert "FIX afair#40: Handle enum attributes while instantiating rows"
Browse files Browse the repository at this point in the history
  • Loading branch information
afair committed Jan 17, 2020
1 parent 7e8dd76 commit 829873f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/postgresql_cursor/cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ def each_array(&block)
def each_instance(klass=nil, &block)
klass ||= @type
self.each_tuple do |row|
klass.send(:instantiate, row)
if ::ActiveRecord::VERSION::MAJOR < 4
model = klass.send(:instantiate,row)
else
@column_types ||= column_types
model = klass.send(:instantiate, row, @column_types)
end
block.call(model)
end
end
Expand Down Expand Up @@ -139,7 +144,12 @@ def each_instance_batch(klass=nil, &block)
klass ||= @type
self.each_batch do |batch|
models = batch.map do |row|
klass.send(:instantiate, row)
if ::ActiveRecord::VERSION::MAJOR < 4
model = klass.send(:instantiate, row)
else
@column_types ||= column_types
model = klass.send(:instantiate, row, @column_types)
end
end
block.call(models)
end
Expand Down

0 comments on commit 829873f

Please sign in to comment.