Commit aef0766f by Cuong Tran

Merge pull request #201 from andys/develop

sort simple_index indexes by name
parents dafd953d a1ee542f
...@@ -151,7 +151,7 @@ module AnnotateModels ...@@ -151,7 +151,7 @@ module AnnotateModels
if options[:simple_indexes] && klass.table_exists?# Check out if this column is indexed if options[:simple_indexes] && klass.table_exists?# Check out if this column is indexed
indices = klass.connection.indexes(klass.table_name) indices = klass.connection.indexes(klass.table_name)
if indices = indices.select { |ind| ind.columns.include? col.name } if indices = indices.select { |ind| ind.columns.include? col.name }
indices.each do |ind| indices.sort_by{|ind| ind.name}.each do |ind|
ind = ind.columns.reject! { |i| i == col.name } ind = ind.columns.reject! { |i| i == col.name }
attrs << (ind.length == 0 ? "indexed" : "indexed => [#{ind.join(", ")}]") attrs << (ind.length == 0 ? "indexed" : "indexed => [#{ind.join(", ")}]")
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment