diff options
| author | Claude Paroz <claude@2xlibre.net> | 2014-09-18 18:11:37 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-09-18 20:00:35 +0200 |
| commit | abc11b0a33fd823ad341ab2cc113c73545eb61e6 (patch) | |
| tree | 6ecc82723a5044ca4e748e11053fa46e7e9e1e5c /django | |
| parent | 4dcfacb5b92dc06c4a351119cf501d842d46d192 (diff) | |
Fixed #23514 -- Prevented queries in PostGISOperations init
Thanks Mattia Procopio for the report.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/operations.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 4fae107d5e..d598d198f8 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -176,10 +176,6 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): 'bboverlaps': PostGISOperator('&&'), } - # Native geometry type support added in PostGIS 2.0. - if self.spatial_version >= (2, 0, 0): - self.geometry = True - # Creating a dictionary lookup of all GIS terms for PostGIS. self.gis_terms = set(['isnull']) self.gis_terms.update(self.geometry_operators) @@ -220,14 +216,33 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): self.union = prefix + 'Union' self.unionagg = prefix + 'Union' + # Following "attributes" are properties due to the spatial_version check and + # to delay database access + @property + def extent3d(self): + if self.spatial_version >= (2, 0, 0): + return self.geom_func_prefix + '3DExtent' + else: + return self.geom_func_prefix + 'Extent3D' + + @property + def length3d(self): if self.spatial_version >= (2, 0, 0): - self.extent3d = prefix + '3DExtent' - self.length3d = prefix + '3DLength' - self.perimeter3d = prefix + '3DPerimeter' + return self.geom_func_prefix + '3DLength' else: - self.extent3d = prefix + 'Extent3D' - self.length3d = prefix + 'Length3D' - self.perimeter3d = prefix + 'Perimeter3D' + return self.geom_func_prefix + 'Length3D' + + @property + def perimeter3d(self): + if self.spatial_version >= (2, 0, 0): + return self.geom_func_prefix + '3DPerimeter' + else: + return self.geom_func_prefix + 'Perimeter3D' + + @property + def geometry(self): + # Native geometry type support added in PostGIS 2.0. + return self.spatial_version >= (2, 0, 0) @cached_property def spatial_version(self): |
