Allow strings to be used in index creation #677

This commit is contained in:
Ross Lawley
2014-06-27 12:49:31 +01:00
parent 1bd83cc9bc
commit 94e177c0ef
3 changed files with 18 additions and 1 deletions

View File

@@ -727,5 +727,20 @@ class IndexesTest(unittest.TestCase):
report.to_mongo())
self.assertEqual(report, Report.objects.get(pk=my_key))
def test_string_indexes(self):
class MyDoc(Document):
provider_ids = DictField()
meta = {
"indexes": ["provider_ids.foo", "provider_ids.bar"],
}
info = MyDoc.objects._collection.index_information()
info = [value['key'] for key, value in info.iteritems()]
self.assertTrue([('provider_ids.foo', 1)] in info)
self.assertTrue([('provider_ids.bar', 1)] in info)
if __name__ == '__main__':
unittest.main()