diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-06-25 16:32:09 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 01:35:38 +0200 |
commit | 6e655732226eef6fa04d8fc0c4ee1f0436688c49 (patch) | |
tree | 747bfe4d1938a7c1a0aed0ea18ebb999ed791806 | |
parent | 47134a04bbce216f9c31473b1a0c1a077d624692 (diff) | |
download | rails-6e655732226eef6fa04d8fc0c4ee1f0436688c49.tar.gz rails-6e655732226eef6fa04d8fc0c4ee1f0436688c49.tar.bz2 rails-6e655732226eef6fa04d8fc0c4ee1f0436688c49.zip |
refactoring the postgres adapter index method to avoid inject and use values_at. [#4976 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 26d88158d3..2fe2ae7136 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -615,15 +615,15 @@ module ActiveRecord indkey = row[2].split(" ") oid = row[3] - columns = query(<<-SQL, "Columns for index #{row[0]} on #{table_name}").inject({}) {|attlist, r| attlist[r[1]] = r[0]; attlist} - SELECT a.attname, a.attnum + columns = Hash[query(<<-SQL, "Columns for index #{row[0]} on #{table_name}")] + SELECT a.attnum, a.attname FROM pg_attribute a WHERE a.attrelid = #{oid} AND a.attnum IN (#{indkey.join(",")}) SQL - column_names = indkey.map {|attnum| columns[attnum] } - column_names.compact.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names) + column_names = columns.values_at(*indkey).compact + column_names.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names) end.compact end |