Skip to content

Commit

Permalink
Merge pull request afair#53 from afair/revert-48-fix-enum-parsing
Browse files Browse the repository at this point in the history
Revert "FIX afair#40: Handle enum attributes while instantiating rows"
  • Loading branch information
afair authored Jan 17, 2020
2 parents 7e8dd76 + 829873f commit 4bec7fa
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 4bec7fa

Please sign in to comment.