Fix #766: Add support for operator
This commit is contained in:
parent
b18d87ddba
commit
225c31d583
@ -5,6 +5,7 @@ Changelog
|
|||||||
|
|
||||||
Changes in 0.9.X - DEV
|
Changes in 0.9.X - DEV
|
||||||
======================
|
======================
|
||||||
|
- Add support for $type operator # 766
|
||||||
- Fix tests for pymongo 2.8+ #877
|
- Fix tests for pymongo 2.8+ #877
|
||||||
- No module named 'django.utils.importlib' (Django dev) #872
|
- No module named 'django.utils.importlib' (Django dev) #872
|
||||||
- Field Choices Now Accept Subclasses of Documents
|
- Field Choices Now Accept Subclasses of Documents
|
||||||
|
@ -11,7 +11,7 @@ __all__ = ('query', 'update')
|
|||||||
|
|
||||||
|
|
||||||
COMPARISON_OPERATORS = ('ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin', 'mod',
|
COMPARISON_OPERATORS = ('ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin', 'mod',
|
||||||
'all', 'size', 'exists', 'not', 'elemMatch')
|
'all', 'size', 'exists', 'not', 'elemMatch', 'type')
|
||||||
GEO_OPERATORS = ('within_distance', 'within_spherical_distance',
|
GEO_OPERATORS = ('within_distance', 'within_spherical_distance',
|
||||||
'within_box', 'within_polygon', 'near', 'near_sphere',
|
'within_box', 'within_polygon', 'near', 'near_sphere',
|
||||||
'max_distance', 'geo_within', 'geo_within_box',
|
'max_distance', 'geo_within', 'geo_within_box',
|
||||||
|
@ -197,5 +197,17 @@ class TransformTest(unittest.TestCase):
|
|||||||
update = transform.update(Location, set__poly={"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]})
|
update = transform.update(Location, set__poly={"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]})
|
||||||
self.assertEqual(update, {'$set': {'poly': {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]}}})
|
self.assertEqual(update, {'$set': {'poly': {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]}}})
|
||||||
|
|
||||||
|
def test_type(self):
|
||||||
|
class Doc(Document):
|
||||||
|
df = DynamicField()
|
||||||
|
Doc(df=True).save()
|
||||||
|
Doc(df=7).save()
|
||||||
|
Doc(df="df").save()
|
||||||
|
self.assertEqual(Doc.objects(df__type=1).count(), 0) # double
|
||||||
|
self.assertEqual(Doc.objects(df__type=8).count(), 1) # bool
|
||||||
|
self.assertEqual(Doc.objects(df__type=2).count(), 1) # str
|
||||||
|
self.assertEqual(Doc.objects(df__type=16).count(), 1) # int
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user