Skip to content

Commit

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

0 comments on commit 7e8dd76

Please sign in to comment.