Skip to content

Commit 829873f

Browse files
authored
Revert "FIX #40: Handle enum attributes while instantiating rows"
1 parent 7e8dd76 commit 829873f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/postgresql_cursor/cursor.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ def each_array(&block)
110110
def each_instance(klass=nil, &block)
111111
klass ||= @type
112112
self.each_tuple do |row|
113-
klass.send(:instantiate, row)
113+
if ::ActiveRecord::VERSION::MAJOR < 4
114+
model = klass.send(:instantiate,row)
115+
else
116+
@column_types ||= column_types
117+
model = klass.send(:instantiate, row, @column_types)
118+
end
114119
block.call(model)
115120
end
116121
end
@@ -139,7 +144,12 @@ def each_instance_batch(klass=nil, &block)
139144
klass ||= @type
140145
self.each_batch do |batch|
141146
models = batch.map do |row|
142-
klass.send(:instantiate, row)
147+
if ::ActiveRecord::VERSION::MAJOR < 4
148+
model = klass.send(:instantiate, row)
149+
else
150+
@column_types ||= column_types
151+
model = klass.send(:instantiate, row, @column_types)
152+
end
143153
end
144154
block.call(models)
145155
end

0 commit comments

Comments
 (0)