Allow fields to be named the same as query operators (#445)
This commit is contained in:
		
							
								
								
									
										3
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -175,4 +175,5 @@ that much better: | |||||||
|  * Paul Uithol (https://github.com/PaulUithol) |  * Paul Uithol (https://github.com/PaulUithol) | ||||||
|  * Thom Knowles (https://github.com/fleat) |  * Thom Knowles (https://github.com/fleat) | ||||||
|  * Paul (https://github.com/squamous) |  * Paul (https://github.com/squamous) | ||||||
|  * Olivier Cortès (https://github.com/Karmak23) |  * Olivier Cortès (https://github.com/Karmak23) | ||||||
|  |  * crazyzubr (https://github.com/crazyzubr) | ||||||
| @@ -4,7 +4,8 @@ Changelog | |||||||
|  |  | ||||||
| Changes in 0.8.4 | Changes in 0.8.4 | ||||||
| ================ | ================ | ||||||
| - Fixed can now exclude subclass fields (#443) | - Allow fields to be named the same as query operators (#445) | ||||||
|  | - Updated field filter logic - can now exclude subclass fields (#443) | ||||||
| - Fixed dereference issue with embedded listfield referencefields (#439) | - Fixed dereference issue with embedded listfield referencefields (#439) | ||||||
| - Fixed slice when using inheritance causing fields to be excluded (#437) | - Fixed slice when using inheritance causing fields to be excluded (#437) | ||||||
| - Fixed ._get_db() attribute after a Document.switch_db() (#441) | - Fixed ._get_db() attribute after a Document.switch_db() (#441) | ||||||
|   | |||||||
| @@ -3691,6 +3691,23 @@ class QuerySetTest(unittest.TestCase): | |||||||
|             '_cls': 'Animal.Cat' |             '_cls': 'Animal.Cat' | ||||||
|         }) |         }) | ||||||
|  |  | ||||||
|  |     def test_can_have_field_same_name_as_query_operator(self): | ||||||
|  |  | ||||||
|  |         class Size(Document): | ||||||
|  |             name = StringField() | ||||||
|  |  | ||||||
|  |         class Example(Document): | ||||||
|  |             size = ReferenceField(Size) | ||||||
|  |  | ||||||
|  |         Size.drop_collection() | ||||||
|  |         Example.drop_collection() | ||||||
|  |  | ||||||
|  |         instance_size = Size(name="Large").save() | ||||||
|  |         Example(size=instance_size).save() | ||||||
|  |  | ||||||
|  |         self.assertEqual(Example.objects(size=instance_size).count(), 1) | ||||||
|  |         self.assertEqual(Example.objects(size__in=[instance_size]).count(), 1) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user