mirror of https://github.com/django/django.git
Refs #34629 -- Changed SDOAGGRTYPE wrapping to Func() in GIS aggregates on Oracle.
This commit is contained in:
parent
1fe0b167af
commit
c1cff3c471
|
@ -4,7 +4,7 @@ from django.contrib.gis.db.models.fields import (
|
||||||
GeometryField,
|
GeometryField,
|
||||||
LineStringField,
|
LineStringField,
|
||||||
)
|
)
|
||||||
from django.db.models import Aggregate, Value
|
from django.db.models import Aggregate, Func, Value
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
__all__ = ["Collect", "Extent", "Extent3D", "MakeLine", "Union"]
|
__all__ = ["Collect", "Extent", "Extent3D", "MakeLine", "Union"]
|
||||||
|
@ -33,16 +33,20 @@ class GeoAggregate(Aggregate):
|
||||||
if not self.is_extent:
|
if not self.is_extent:
|
||||||
tolerance = self.extra.get("tolerance") or getattr(self, "tolerance", 0.05)
|
tolerance = self.extra.get("tolerance") or getattr(self, "tolerance", 0.05)
|
||||||
clone = self.copy()
|
clone = self.copy()
|
||||||
clone.set_source_expressions(
|
source_expressions = self.get_source_expressions()
|
||||||
[
|
if self.filter:
|
||||||
*self.get_source_expressions(),
|
source_expressions.pop()
|
||||||
|
spatial_type_expr = Func(
|
||||||
|
*source_expressions,
|
||||||
Value(tolerance),
|
Value(tolerance),
|
||||||
]
|
function="SDOAGGRTYPE",
|
||||||
)
|
output_field=self.output_field,
|
||||||
template = "%(function)s(SDOAGGRTYPE(%(expressions)s))"
|
|
||||||
return clone.as_sql(
|
|
||||||
compiler, connection, template=template, **extra_context
|
|
||||||
)
|
)
|
||||||
|
source_expressions = [spatial_type_expr]
|
||||||
|
if self.filter:
|
||||||
|
source_expressions.append(self.filter)
|
||||||
|
clone.set_source_expressions(source_expressions)
|
||||||
|
return clone.as_sql(compiler, connection, **extra_context)
|
||||||
return self.as_sql(compiler, connection, **extra_context)
|
return self.as_sql(compiler, connection, **extra_context)
|
||||||
|
|
||||||
def resolve_expression(
|
def resolve_expression(
|
||||||
|
|
Loading…
Reference in New Issue