fixes for #325 issue
This commit is contained in:
		| @@ -666,6 +666,9 @@ class ReferenceField(BaseField): | |||||||
|         return pymongo.dbref.DBRef(collection, id_) |         return pymongo.dbref.DBRef(collection, id_) | ||||||
|  |  | ||||||
|     def prepare_query_value(self, op, value): |     def prepare_query_value(self, op, value): | ||||||
|  |         if value is None: | ||||||
|  |             return None | ||||||
|  |  | ||||||
|         return self.to_mongo(value) |         return self.to_mongo(value) | ||||||
|  |  | ||||||
|     def validate(self, value): |     def validate(self, value): | ||||||
| @@ -743,6 +746,9 @@ class GenericReferenceField(BaseField): | |||||||
|         return {'_cls': document._class_name, '_ref': ref} |         return {'_cls': document._class_name, '_ref': ref} | ||||||
|  |  | ||||||
|     def prepare_query_value(self, op, value): |     def prepare_query_value(self, op, value): | ||||||
|  |         if value is None: | ||||||
|  |             return None | ||||||
|  |  | ||||||
|         return self.to_mongo(value) |         return self.to_mongo(value) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							| @@ -47,5 +47,5 @@ setup(name='mongoengine', | |||||||
|       classifiers=CLASSIFIERS, |       classifiers=CLASSIFIERS, | ||||||
|       install_requires=['pymongo'], |       install_requires=['pymongo'], | ||||||
|       test_suite='tests', |       test_suite='tests', | ||||||
|       tests_require=['blinker', 'django==1.3'] |       tests_require=['blinker', 'django>=1.3'] | ||||||
| ) | ) | ||||||
|   | |||||||
| @@ -997,10 +997,16 @@ class FieldTest(unittest.TestCase): | |||||||
|         mongodb = Product(name='MongoDB', company=ten_gen) |         mongodb = Product(name='MongoDB', company=ten_gen) | ||||||
|         mongodb.save() |         mongodb.save() | ||||||
|  |  | ||||||
|  |         me = Product(name='MongoEngine') | ||||||
|  |         me.save() | ||||||
|  |  | ||||||
|         obj = Product.objects(company=ten_gen).first() |         obj = Product.objects(company=ten_gen).first() | ||||||
|         self.assertEqual(obj, mongodb) |         self.assertEqual(obj, mongodb) | ||||||
|         self.assertEqual(obj.company, ten_gen) |         self.assertEqual(obj.company, ten_gen) | ||||||
|  |  | ||||||
|  |         obj = Product.objects(company=None).first() | ||||||
|  |         self.assertEqual(obj, me) | ||||||
|  |  | ||||||
|     def test_reference_query_conversion(self): |     def test_reference_query_conversion(self): | ||||||
|         """Ensure that ReferenceFields can be queried using objects and values |         """Ensure that ReferenceFields can be queried using objects and values | ||||||
|         of the type of the primary key of the referenced object. |         of the type of the primary key of the referenced object. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user