diff options
author | Marcel Molina <marcel@vernix.org> | 2005-10-14 14:01:17 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2005-10-14 14:01:17 +0000 |
commit | e2da98e212e297ad8cc99a5806b01e8e1512e7ce (patch) | |
tree | d4e7762a2c20e1dc611683eae7704a98c515170b | |
parent | 5fa8793f02b58509a90eed69e8dc3d199f89b4ad (diff) | |
download | rails-e2da98e212e297ad8cc99a5806b01e8e1512e7ce.tar.gz rails-e2da98e212e297ad8cc99a5806b01e8e1512e7ce.tar.bz2 rails-e2da98e212e297ad8cc99a5806b01e8e1512e7ce.zip |
Back out of [2548].
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2581 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index b26d4d35c9..e7bedaee9e 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -250,24 +250,24 @@ module ActiveRecord def select(sql, name = nil) res = execute(sql, name) results = res.result - rows = [] - if results.length > 0 - fields = res.fields - hash_prototype = fields.inject({}){ |proto, field| proto[field] = nil; proto } - results.each do |row| - hashed_row = hash_prototype.clone - row.each_index do |col_num| - if res.type(col_num) == BYTEA_COLUMN_TYPE_OID - hashed_row[fields[col_num]] = unescape_bytea(row[col_num]) - else - hashed_row[fields[col_num]] = row[col_num] - end - end - rows << hashed_row - end - end - rows - end + rows = [] + if results.length > 0 + fields = res.fields + results.each do |row| + hashed_row = {} + row.each_index do |cel_index| + column = row[cel_index] + if res.type(cel_index) == BYTEA_COLUMN_TYPE_OID + column = unescape_bytea(column) + end + hashed_row[fields[cel_index]] = column + end + rows << hashed_row + end + end + return rows + end + def escape_bytea(s) if PGconn.respond_to? :escape_bytea self.class.send(:define_method, :escape_bytea) do |s| |