Skip to content

Commit 0325a62

Browse files
authored
Merge pull request #1626 from erdenezul/pointfield_aspymongo
added as_pymongo test for PointField #1311
2 parents 3a55388 + 0d1e72a commit 0325a62

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/queryset/geo.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,24 @@ class Road(Document):
510510
roads = Road.objects.filter(poly__geo_intersects={"$geometry": polygon}).count()
511511
self.assertEqual(1, roads)
512512

513+
def test_aspymongo_with_only(self):
514+
"""Ensure as_pymongo works with only"""
515+
class Place(Document):
516+
location = PointField()
517+
518+
Place.drop_collection()
519+
p = Place(location=[24.946861267089844, 60.16311983618494])
520+
p.save()
521+
qs = Place.objects().only('location')
522+
self.assertDictEqual(
523+
qs.as_pymongo()[0]['location'],
524+
{u'type': u'Point',
525+
u'coordinates': [
526+
24.946861267089844,
527+
60.16311983618494]
528+
}
529+
)
530+
513531
def test_2dsphere_point_sets_correctly(self):
514532
class Location(Document):
515533
loc = PointField()

0 commit comments

Comments
 (0)