Fixed #28896 -- Reallowed filtering a queryset with GeometryField=None.
Regression in 58da81a5a3
.
This commit is contained in:
parent
10bfa876be
commit
da71e4bb08
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue