Updated geo_index checking to be recursive

Fixes #127 - Embedded Documents can declare geo indexes and have
them created automatically
This commit is contained in:
Ross Lawley
2011-06-20 15:41:23 +01:00
parent e3cd398f70
commit 08ba51f714
4 changed files with 129 additions and 98 deletions

View File

@@ -494,12 +494,11 @@ class QuerySet(object):
self._collection.ensure_index('_types',
background=background, **index_opts)
# Ensure all needed field indexes are created
for field in self._document._fields.values():
if field.__class__._geo_index:
index_spec = [(field.db_field, pymongo.GEO2D)]
self._collection.ensure_index(index_spec,
background=background, **index_opts)
# Add geo indicies
for field in self._document._geo_indices():
index_spec = [(field.db_field, pymongo.GEO2D)]
self._collection.ensure_index(index_spec,
background=background, **index_opts)
return self._collection_obj