mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	[2.0.x] Fixed #28896 -- Reallowed filtering a queryset with GeometryField=None.
Regression in58da81a5a3. Backport ofda71e4bb08from master
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							a5c6040447
						
					
				
				
					commit
					ce26ec0163
				
			| @@ -167,6 +167,8 @@ class BaseSpatialField(Field): | |||||||
|  |  | ||||||
|     def get_prep_value(self, value): |     def get_prep_value(self, value): | ||||||
|         obj = super().get_prep_value(value) |         obj = super().get_prep_value(value) | ||||||
|  |         if obj is None: | ||||||
|  |             return None | ||||||
|         # When the input is not a geometry or raster, attempt to construct one |         # When the input is not a geometry or raster, attempt to construct one | ||||||
|         # from the given string input. |         # from the given string input. | ||||||
|         if isinstance(obj, GEOSGeometry): |         if isinstance(obj, GEOSGeometry): | ||||||
|   | |||||||
| @@ -21,3 +21,5 @@ Bugfixes | |||||||
| * Fixed a regression in caching of a ``GenericForeignKey`` when the referenced | * Fixed a regression in caching of a ``GenericForeignKey`` when the referenced | ||||||
|   model instance uses more than one level of multi-table inheritance |   model instance uses more than one level of multi-table inheritance | ||||||
|   (:ticket:`28856`). |   (:ticket:`28856`). | ||||||
|  |  | ||||||
|  | * Reallowed filtering a queryset with ``GeometryField=None`` (:ticket:`28896`). | ||||||
|   | |||||||
| @@ -385,6 +385,9 @@ class GeoLookupTest(TestCase): | |||||||
|         # Puerto Rico should be NULL (it's a commonwealth unincorporated territory) |         # Puerto Rico should be NULL (it's a commonwealth unincorporated territory) | ||||||
|         self.assertEqual(1, len(nullqs)) |         self.assertEqual(1, len(nullqs)) | ||||||
|         self.assertEqual('Puerto Rico', nullqs[0].name) |         self.assertEqual('Puerto Rico', nullqs[0].name) | ||||||
|  |         # GeometryField=None is an alias for __isnull=True. | ||||||
|  |         self.assertCountEqual(State.objects.filter(poly=None), nullqs) | ||||||
|  |         self.assertCountEqual(State.objects.exclude(poly=None), validqs) | ||||||
|  |  | ||||||
|         # The valid states should be Colorado & Kansas |         # The valid states should be Colorado & Kansas | ||||||
|         self.assertEqual(2, len(validqs)) |         self.assertEqual(2, len(validqs)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user