Permalink
Browse files

refactor PostgreSQLAdapter#result_as_array to create fewer Range objects

  • Loading branch information...
1 parent 7c4e040 commit c9710a43ff6cdc536f08983b007768ae6a66dd10 @tenderlove tenderlove committed Jul 13, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -431,15 +431,15 @@ def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
def result_as_array(res) #:nodoc:
# check if we have any binary column and if they need escaping
unescape_col = []
- for j in 0...res.nfields do
+ res.nfields.times do |j|
# unescape string passed BYTEA field (OID == 17)
unescape_col << ( res.ftype(j)==17 )
end
ary = []
- for i in 0...res.ntuples do
+ res.ntuples.times do |i|
ary << []
- for j in 0...res.nfields do
+ res.nfields.times do |j|
data = res.getvalue(i,j)
data = unescape_bytea(data) if unescape_col[j] and data.is_a?(String)
ary[i] << data

0 comments on commit c9710a4

Please sign in to comment.