Geo SON tweaks
This commit is contained in:
parent
de9ba12779
commit
89b9b60e0c
@ -117,10 +117,9 @@ def query(_doc_cls=None, _field_operation=False, **query):
|
||||
mongo_query[key].update(value)
|
||||
# $maxDistance needs to come last - convert to SON
|
||||
value_dict = mongo_query[key]
|
||||
if ('$maxDistance' in value_dict and '$near' in value_dict and
|
||||
isinstance(value_dict['$near'], dict)):
|
||||
|
||||
if ('$maxDistance' in value_dict and '$near' in value_dict):
|
||||
value_son = SON()
|
||||
if isinstance(value_dict['$near'], dict):
|
||||
for k, v in value_dict.iteritems():
|
||||
if k == '$maxDistance':
|
||||
continue
|
||||
@ -130,6 +129,12 @@ def query(_doc_cls=None, _field_operation=False, **query):
|
||||
else:
|
||||
value_son['$near'] = SON(value_son['$near'])
|
||||
value_son['$near']['$maxDistance'] = value_dict['$maxDistance']
|
||||
else:
|
||||
for k, v in value_dict.iteritems():
|
||||
if k == '$maxDistance':
|
||||
continue
|
||||
value_son[k] = v
|
||||
value_son['$maxDistance'] = value_dict['$maxDistance']
|
||||
|
||||
mongo_query[key] = value_son
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user