1
0
mirror of https://github.com/django/django.git synced 2025-01-03 06:55:47 +00:00

Refs #34629 -- Changed SDOAGGRTYPE wrapping to Func() in GIS aggregates on Oracle.

This commit is contained in:
Mariusz Felisiak 2023-06-16 12:01:18 +02:00
parent 1fe0b167af
commit c1cff3c471

View File

@ -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()
Value(tolerance), spatial_type_expr = Func(
] *source_expressions,
) Value(tolerance),
template = "%(function)s(SDOAGGRTYPE(%(expressions)s))" function="SDOAGGRTYPE",
return clone.as_sql( output_field=self.output_field,
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(