diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 06:16:54 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 06:16:54 -0700 |
commit | 2a47e7ef105559c4c931efff8fd14c454a21cf7a (patch) | |
tree | 1dcbd44558a32cbc608b9de4cb0fd38fb094983c /activerecord/lib/active_record | |
parent | 2e07260f36f3e192e5f0b51b287700b419fd1019 (diff) | |
download | rails-2a47e7ef105559c4c931efff8fd14c454a21cf7a.tar.gz rails-2a47e7ef105559c4c931efff8fd14c454a21cf7a.tar.bz2 rails-2a47e7ef105559c4c931efff8fd14c454a21cf7a.zip |
only do string substitution on column names once, remove intermediate data structures
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 394daef473..fc4d84a4f2 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -314,13 +314,12 @@ module ActiveRecord protected def select(sql, name = nil, binds = []) #:nodoc: - exec(sql, name, binds).map do |row| - record = {} - row.each do |key, value| - record[key.sub(/^"?\w+"?\./, '')] = value - end - record - end + result = exec(sql, name, binds) + columns = result.columns.map { |column| + column.sub(/^"?\w+"?\./, '') + } + + result.rows.map { |row| Hash[columns.zip(row)] } end def table_structure(table_name) |