@@ -431,7 +431,7 @@ def test_intersection(self):
431431 self .assertIs (c .inter .empty , True )
432432
433433 @skipUnlessDBFeature ("supports_empty_geometries" , "has_IsEmpty_function" )
434- def test_isempty (self ):
434+ def test_isempty_geometry_empty (self ):
435435 empty = City .objects .create (name = "Nowhere" , point = Point (srid = 4326 ))
436436 City .objects .create (name = "Somewhere" , point = Point (6.825 , 47.1 , srid = 4326 ))
437437 self .assertSequenceEqual (
@@ -442,6 +442,18 @@ def test_isempty(self):
442442 )
443443 self .assertSequenceEqual (City .objects .filter (point__isempty = True ), [empty ])
444444
445+ @skipUnlessDBFeature ("has_IsEmpty_function" )
446+ def test_isempty_geometry_null (self ):
447+ nowhere = State .objects .create (name = "Nowhere" , poly = None )
448+ qs = State .objects .annotate (isempty = functions .IsEmpty ("poly" ))
449+ self .assertSequenceEqual (qs .filter (isempty = None ), [nowhere ])
450+ self .assertSequenceEqual (
451+ qs .filter (isempty = False ).order_by ("name" ).values_list ("name" , flat = True ),
452+ ["Colorado" , "Kansas" ],
453+ )
454+ self .assertSequenceEqual (qs .filter (isempty = True ), [])
455+ self .assertSequenceEqual (State .objects .filter (poly__isempty = True ), [])
456+
445457 @skipUnlessDBFeature ("has_IsValid_function" )
446458 def test_isvalid (self ):
447459 valid_geom = fromstr ("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))" )
0 commit comments