Fixed index ordering
This commit is contained in:
parent
e8748651b5
commit
cd44c3c918
|
@ -355,6 +355,7 @@ Sean Cribbs, seancribbs on github
|
||||||
|
|
||||||
Sunny Hirai
|
Sunny Hirai
|
||||||
* Suggested hashcode fix for Mongo::ObjectID
|
* Suggested hashcode fix for Mongo::ObjectID
|
||||||
|
* Noted index ordering bug.
|
||||||
|
|
||||||
= License
|
= License
|
||||||
|
|
||||||
|
|
|
@ -505,4 +505,5 @@ EOS
|
||||||
indexes.join("_")
|
indexes.join("_")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -422,7 +422,7 @@ module Mongo
|
||||||
sel = {:ns => full_collection_name(collection_name)}
|
sel = {:ns => full_collection_name(collection_name)}
|
||||||
info = {}
|
info = {}
|
||||||
Cursor.new(Collection.new(self, SYSTEM_INDEX_COLLECTION), :selector => sel).each { |index|
|
Cursor.new(Collection.new(self, SYSTEM_INDEX_COLLECTION), :selector => sel).each { |index|
|
||||||
info[index['name']] = index['key'].to_a
|
info[index['name']] = index['key'].map
|
||||||
}
|
}
|
||||||
info
|
info
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,6 +69,7 @@ class OrderedHash < Hash
|
||||||
@ordered_keys.each { |k| yield k, self[k] }
|
@ordered_keys.each { |k| yield k, self[k] }
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
alias :each_pair :each
|
||||||
|
|
||||||
def values
|
def values
|
||||||
collect { |k, v| v }
|
collect { |k, v| v }
|
||||||
|
|
|
@ -398,4 +398,27 @@ class TestCollection < Test::Unit::TestCase
|
||||||
assert_equal 1, @collection.size
|
assert_equal 1, @collection.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Creating indexes " do
|
||||||
|
setup do
|
||||||
|
@collection = @@db.collection('test-collection')
|
||||||
|
end
|
||||||
|
|
||||||
|
should "generate indexes in the proper order" do
|
||||||
|
@collection.expects(:insert_documents) do |sel, coll, safe|
|
||||||
|
assert_equal 'b_1_a_1', sel[:name]
|
||||||
|
end
|
||||||
|
@collection.create_index([['b', 1], ['a', 1]])
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with an index created" do
|
||||||
|
setup do
|
||||||
|
@collection.create_index([['b', 1], ['a', 1]])
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return properly ordered index information" do
|
||||||
|
assert_equal [['b', 1], ['a', 1]], @collection.index_information["b_1_a_1"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue