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:
parent
e3cd398f70
commit
08ba51f714
4 changed files with 129 additions and 98 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue