mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00:00 
			
		
		
		
	Fixed #24136 -- Prevented crash when convert_extent input is None
Thanks Max Demars for the report.
This commit is contained in:
		| @@ -193,6 +193,8 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): | |||||||
|         the bounding box text returned by PostGIS (`box` argument), for |         the bounding box text returned by PostGIS (`box` argument), for | ||||||
|         example: "BOX(-90.0 30.0, -85.0 40.0)". |         example: "BOX(-90.0 30.0, -85.0 40.0)". | ||||||
|         """ |         """ | ||||||
|  |         if box is None: | ||||||
|  |             return None | ||||||
|         ll, ur = box[4:-1].split(',') |         ll, ur = box[4:-1].split(',') | ||||||
|         xmin, ymin = map(float, ll.split()) |         xmin, ymin = map(float, ll.split()) | ||||||
|         xmax, ymax = map(float, ur.split()) |         xmax, ymax = map(float, ur.split()) | ||||||
| @@ -204,6 +206,8 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): | |||||||
|         the 3d bounding-box text returned by PostGIS (`box3d` argument), for |         the 3d bounding-box text returned by PostGIS (`box3d` argument), for | ||||||
|         example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)". |         example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)". | ||||||
|         """ |         """ | ||||||
|  |         if box3d is None: | ||||||
|  |             return None | ||||||
|         ll, ur = box3d[6:-1].split(',') |         ll, ur = box3d[6:-1].split(',') | ||||||
|         xmin, ymin, zmin = map(float, ll.split()) |         xmin, ymin, zmin = map(float, ll.split()) | ||||||
|         xmax, ymax, zmax = map(float, ur.split()) |         xmax, ymax, zmax = map(float, ur.split()) | ||||||
|   | |||||||
| @@ -134,6 +134,8 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations): | |||||||
|         """ |         """ | ||||||
|         Convert the polygon data received from Spatialite to min/max values. |         Convert the polygon data received from Spatialite to min/max values. | ||||||
|         """ |         """ | ||||||
|  |         if box is None: | ||||||
|  |             return None | ||||||
|         shell = Geometry(box, srid).shell |         shell = Geometry(box, srid).shell | ||||||
|         xmin, ymin = shell[0][:2] |         xmin, ymin = shell[0][:2] | ||||||
|         xmax, ymax = shell[2][:2] |         xmax, ymax = shell[2][:2] | ||||||
|   | |||||||
| @@ -222,6 +222,7 @@ class Geo3DTest(TestCase): | |||||||
|  |  | ||||||
|         for e3d in [extent1, extent2]: |         for e3d in [extent1, extent2]: | ||||||
|             check_extent3d(e3d) |             check_extent3d(e3d) | ||||||
|  |         self.assertIsNone(City3D.objects.none().extent3d()) | ||||||
|  |  | ||||||
|     def test_perimeter(self): |     def test_perimeter(self): | ||||||
|         """ |         """ | ||||||
|   | |||||||
| @@ -482,6 +482,7 @@ class GeoQuerySetTest(TestCase): | |||||||
|  |  | ||||||
|         for val, exp in zip(extent, expected): |         for val, exp in zip(extent, expected): | ||||||
|             self.assertAlmostEqual(exp, val, 4) |             self.assertAlmostEqual(exp, val, 4) | ||||||
|  |         self.assertIsNone(City.objects.filter(name=('Smalltown')).extent()) | ||||||
|  |  | ||||||
|     @skipUnlessDBFeature("has_force_rhr_method") |     @skipUnlessDBFeature("has_force_rhr_method") | ||||||
|     def test_force_rhr(self): |     def test_force_rhr(self): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user