Skip to content

Commit

Permalink
Merge branch 'add_support_for_bitwise_query_operators_#1055'
Browse files Browse the repository at this point in the history
Closes #1053
  • Loading branch information
nicolaiarocci committed Nov 7, 2017
2 parents 8b0515b + d793d5c commit 2d2ad29
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Patches and Contributions
- Peter Darrow
- Petr Jašek
- Prayag Verma
- Qiang Zhang
- Ralph Smith
- Raychee
- Robert Wlodarczyk
Expand Down
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Development

Version 0.8
~~~~~~~~~~~
- Fix: Aggregation query parameter does not replace keys in the lists. Closes
- New: Add support for MongoDB bitwise query operators ``$bitsAllClear``,
``bitsAllSet``, ``bitsAnyClear``, ``bitsAnySet``. Closes 1053 (Qiang Zhang).
- Fix: Aggregation query parameter does not replace keys in the lists. Closes
#1025 (Serge Kir).
- Fix: Removed OrderedDict dependency; use ``OrderedDict`` from
``backport_collections`` instead (Carl George).
Expand Down
3 changes: 2 additions & 1 deletion eve/io/mongo/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class Mongo(DataLayer):
['$options', '$search', '$language'] +
['$exists', '$type'] +
['$geoWithin', '$geoIntersects', '$near', '$nearSphere'] +
['$all', '$elemMatch', '$size']
['$all', '$elemMatch', '$size'] +
['$bitsAllClear', '$bitsAllSet', '$bitsAnyClear', '$bitsAnySet']
)

def init_app(self, app):
Expand Down
26 changes: 25 additions & 1 deletion eve/tests/methods/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,30 @@ def test_get_aggregation_pagination(self):
items = response['_items']
self.assertEqual(len(items), num)

def test_get_query_bitwise_query_operators(self):
del(self.domain['contacts']['schema']['ref']['required'])
response, status = self.delete(self.known_resource_url)
self.assert204(status)

data = {'prog': 20} # 00010100
response, status = self.post(self.known_resource_url, data=data)
self.assert201(status)

where = '?where={"prog": {"$bitsAllClear": [1, 5]}}'
response, status = self.get(self.known_resource, where)
self.assert200(status)
items = response['_items']
self.assertEqual(1, len(items))

response, status = self.delete(self.known_resource_url)
self.assert204(status)

where = '?where={"prog": {"$bitsAllClear": [2, 5]}}'
response, status = self.get(self.known_resource, where)
self.assert200(status)
items = response['_items']
self.assertEqual(0, len(items))

def assertGet(self, response, status, resource=None):
self.assert200(status)

Expand Down Expand Up @@ -1696,7 +1720,7 @@ def test_getitem_lookup_field_as_string(self):
# treated as a string when 'query_objectid_as_string' is set to True.
# See PR #552.
data = {'id': '507c7f79bcf86cd7994f6c0e', 'name': 'john'}
response, status = self.post('ids', data=data)
response, status = self.post(self.known_resource_url, data=data)
self.assert201(status)
response, status = self.get('ids', item='507c7f79bcf86cd7994f6c0e')
self.assert200(status)
Expand Down

0 comments on commit 2d2ad29

Please # to comment.