1
0
mirror of https://github.com/django/django.git synced 2025-10-27 15:46:10 +00:00

Added validation to BaseSpatialFeatures.has_<Func>_function.

This commit is contained in:
Tim Graham
2025-06-05 16:18:56 -04:00
committed by GitHub
parent f0a87895ff
commit cf1a80fc2d
4 changed files with 26 additions and 3 deletions

View File

@@ -2,6 +2,8 @@ import re
from django.contrib.gis.db import models
from .operations import BaseSpatialOperations
class BaseSpatialFeatures:
gis_enabled = True
@@ -107,5 +109,11 @@ class BaseSpatialFeatures:
m = re.match(r"has_(\w*)_function$", name)
if m:
func_name = m[1]
if func_name not in BaseSpatialOperations.unsupported_functions:
raise ValueError(
f"DatabaseFeatures.has_{func_name}_function isn't valid. "
f'Is "{func_name}" missing from '
"BaseSpatialOperations.unsupported_functions?"
)
return func_name not in self.connection.ops.unsupported_functions
raise AttributeError

View File

@@ -39,13 +39,17 @@ class BaseSpatialOperations:
"AsGML",
"AsKML",
"AsSVG",
"AsWKB",
"AsWKT",
"Azimuth",
"BoundingCircle",
"Centroid",
"ClosestPoint",
"Difference",
"Distance",
"DistanceSpheroid",
"Envelope",
"ForcePolygonCW",
"FromWKB",
"FromWKT",
"GeoHash",