Fix for #1176 -- similar to https://github.com/MongoEngine/mongoengine/pull/982 but for update.
				
					
				
			This commit is contained in:
		
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -239,3 +239,4 @@ that much better: | ||||
|  * Joshua Nedrud (https://github.com/Neurostack) | ||||
|  * Shu Shen (https://github.com/shushen) | ||||
|  * xiaost7 (https://github.com/xiaost7) | ||||
|  * Victor Varvaryuk | ||||
|   | ||||
| @@ -99,7 +99,7 @@ Some simple examples of what MongoEngine code looks like: | ||||
| Tests | ||||
| ===== | ||||
| To run the test suite, ensure you are running a local instance of MongoDB on | ||||
| the standard port, and run: ``python setup.py nosetests``. | ||||
| the standard port and have installed ``nose`` and ``rednose``, and run: ``python setup.py nosetests``. | ||||
|  | ||||
| To run the test suite on every supported Python version and every supported PyMongo version, | ||||
| you can use ``tox``. | ||||
|   | ||||
| @@ -16,6 +16,7 @@ Changes in 0.10.7 - DEV | ||||
| - Fixed AttributeError when initializing EmbeddedDocument with positional args. #681 | ||||
| - Fixed no_cursor_timeout error with pymongo 3.0+ #1304 | ||||
| - Replaced map-reduce based QuerySet.sum/average with aggregation-based implementations #1336 | ||||
| - Fixed support for `__` to escape field names that match operators names in `update` #1351 | ||||
|  | ||||
| Changes in 0.10.6 | ||||
| ================= | ||||
|   | ||||
| @@ -44,7 +44,7 @@ def query(_doc_cls=None, **kwargs): | ||||
|         if len(parts) > 1 and parts[-1] in MATCH_OPERATORS: | ||||
|             op = parts.pop() | ||||
|  | ||||
|         # Allw to escape operator-like field name by __ | ||||
|         # Allow to escape operator-like field name by __ | ||||
|         if len(parts) > 1 and parts[-1] == "": | ||||
|             parts.pop() | ||||
|  | ||||
| @@ -212,6 +212,10 @@ def update(_doc_cls=None, **update): | ||||
|         if parts[-1] in COMPARISON_OPERATORS: | ||||
|             match = parts.pop() | ||||
|  | ||||
|         # Allow to escape operator-like field name by __ | ||||
|         if len(parts) > 1 and parts[-1] == "": | ||||
|             parts.pop() | ||||
|  | ||||
|         if _doc_cls: | ||||
|             # Switch field names to proper names [set in Field(name='foo')] | ||||
|             try: | ||||
|   | ||||
| @@ -224,6 +224,10 @@ class TransformTest(unittest.TestCase): | ||||
|         self.assertEqual(1, Doc.objects(item__type__="axe").count()) | ||||
|         self.assertEqual(1, Doc.objects(item__name__="Heroic axe").count()) | ||||
|  | ||||
|         Doc.objects(id=doc.id).update(set__item__type__='sword') | ||||
|         self.assertEqual(1, Doc.objects(item__type__="sword").count()) | ||||
|         self.assertEqual(0, Doc.objects(item__type__="axe").count()) | ||||
|  | ||||
|     def test_understandable_error_raised(self): | ||||
|         class Event(Document): | ||||
|             title = StringField() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user