Skip to content

Commit

Permalink
Refs #34629 -- Changed SDOAGGRTYPE wrapping to Func() in GIS aggregat…
Browse files Browse the repository at this point in the history
…es on Oracle.
  • Loading branch information
felixxm committed Jun 16, 2023
1 parent 1fe0b16 commit c1cff3c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions django/contrib/gis/db/models/aggregates.py
Expand Up @@ -4,7 +4,7 @@
GeometryField,
LineStringField,
)
from django.db.models import Aggregate, Value
from django.db.models import Aggregate, Func, Value
from django.utils.functional import cached_property

__all__ = ["Collect", "Extent", "Extent3D", "MakeLine", "Union"]
Expand Down Expand Up @@ -33,16 +33,20 @@ def as_oracle(self, compiler, connection, **extra_context):
if not self.is_extent:
tolerance = self.extra.get("tolerance") or getattr(self, "tolerance", 0.05)
clone = self.copy()
clone.set_source_expressions(
[
*self.get_source_expressions(),
Value(tolerance),
]
)
template = "%(function)s(SDOAGGRTYPE(%(expressions)s))"
return clone.as_sql(
compiler, connection, template=template, **extra_context
source_expressions = self.get_source_expressions()
if self.filter:
source_expressions.pop()
spatial_type_expr = Func(
*source_expressions,
Value(tolerance),
function="SDOAGGRTYPE",
output_field=self.output_field,
)
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)

def resolve_expression(
Expand Down

0 comments on commit c1cff3c

Please sign in to comment.