--
Ticket URL: <https://code.djangoproject.com/ticket/25448>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by claudep):
Planned modification (to be tested):
{{{
#!diff
diff --git a/django/contrib/gis/db/models/lookups.py
b/django/contrib/gis/db/models/lookups.py
index 46104a2..33fa635 100644
--- a/django/contrib/gis/db/models/lookups.py
+++ b/django/contrib/gis/db/models/lookups.py
@@ -93,7 +93,7 @@ class GISLookup(Lookup):
sql_params.extend(rhs_params)
template_params = {'lhs': lhs_sql, 'rhs': rhs_sql}
- backend_op = connection.ops.gis_operators[self.lookup_name]
+ backend_op = connection.ops.gis_operators.get(self.lookup_name,
self.lookup_name)
return backend_op.as_sql(connection, self, template_params,
sql_params)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25448#comment:1>
Comment (by claudep):
Planned feature (to be tested):
{{{
#!diff
diff --git a/django/contrib/gis/db/models/lookups.py
b/django/contrib/gis/db/models/lookups.py
index 46104a2..ed993ca 100644
--- a/django/contrib/gis/db/models/lookups.py
+++ b/django/contrib/gis/db/models/lookups.py
@@ -87,13 +87,16 @@ class GISLookup(Lookup):
rhs = connection.ops.get_geom_placeholder(self.lhs.output_field,
geom, compiler)
return rhs, rhs_params
+ def get_operator(connection):
+ return connection.ops.gis_operators.get[self.lookup_name]
+
def as_sql(self, compiler, connection):
lhs_sql, sql_params = self.process_lhs(compiler, connection)
rhs_sql, rhs_params = self.process_rhs(compiler, connection)
sql_params.extend(rhs_params)
template_params = {'lhs': lhs_sql, 'rhs': rhs_sql}
- backend_op = connection.ops.gis_operators[self.lookup_name]
+ backend_op = self.get_operator(connection)
return backend_op.as_sql(connection, self, template_params,
sql_params)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25448#comment:1>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/25448#comment:2>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/25448#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"c9a02bc8f5114d95079f72dd22aaeec36899117e" c9a02bc8]:
{{{
#!CommitTicketReference repository=""
revision="c9a02bc8f5114d95079f72dd22aaeec36899117e"
Fixed #25448 -- Eased GISLookup subclassing with custom lookups
When someone needs to build a custom backend-specific GIS lookup, it
is much easier done if getting the spatial operator class happens in
a dedicated method (no need to rewrite the entire as_sql() method).
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25448#comment:4>