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