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:
@@ -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
|
||||
|
||||
@@ -39,13 +39,17 @@ class BaseSpatialOperations:
|
||||
"AsGML",
|
||||
"AsKML",
|
||||
"AsSVG",
|
||||
"AsWKB",
|
||||
"AsWKT",
|
||||
"Azimuth",
|
||||
"BoundingCircle",
|
||||
"Centroid",
|
||||
"ClosestPoint",
|
||||
"Difference",
|
||||
"Distance",
|
||||
"DistanceSpheroid",
|
||||
"Envelope",
|
||||
"ForcePolygonCW",
|
||||
"FromWKB",
|
||||
"FromWKT",
|
||||
"GeoHash",
|
||||
|
||||
Reference in New Issue
Block a user