Fixed problem of ordering when using near_sphere operator
This commit is contained in:
parent
5efabdcea3
commit
d96fcdb35c
@ -128,7 +128,8 @@ def query(_doc_cls=None, _field_operation=False, **query):
|
|||||||
mongo_query[key].update(value)
|
mongo_query[key].update(value)
|
||||||
# $max/minDistance needs to come last - convert to SON
|
# $max/minDistance needs to come last - convert to SON
|
||||||
value_dict = mongo_query[key]
|
value_dict = mongo_query[key]
|
||||||
if ('$maxDistance' in value_dict or '$minDistance' in value_dict) and '$near' in value_dict:
|
if ('$maxDistance' in value_dict or '$minDistance' in value_dict) and \
|
||||||
|
('$near' in value_dict or '$nearSphere' in value_dict):
|
||||||
value_son = SON()
|
value_son = SON()
|
||||||
for k, v in value_dict.iteritems():
|
for k, v in value_dict.iteritems():
|
||||||
if k == '$maxDistance' or k == '$minDistance':
|
if k == '$maxDistance' or k == '$minDistance':
|
||||||
|
@ -182,13 +182,6 @@ class GeoQueriesTest(unittest.TestCase):
|
|||||||
|
|
||||||
points = Point.objects(location__near_sphere=[-122, 37.5],
|
points = Point.objects(location__near_sphere=[-122, 37.5],
|
||||||
location__max_distance=60 / earth_radius)
|
location__max_distance=60 / earth_radius)
|
||||||
# This test is sometimes failing with Mongo internals non-sense.
|
|
||||||
# See https://travis-ci.org/MongoEngine/mongoengine/builds/58729101
|
|
||||||
try:
|
|
||||||
points.count()
|
|
||||||
except OperationFailure:
|
|
||||||
raise SkipTest("Sometimes MongoDB ignores its capacities on maxDistance")
|
|
||||||
|
|
||||||
self.assertEqual(points.count(), 2)
|
self.assertEqual(points.count(), 2)
|
||||||
|
|
||||||
# Test query works with max_distance being farer from one point
|
# Test query works with max_distance being farer from one point
|
||||||
|
Loading…
x
Reference in New Issue
Block a user