Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed Extract -> Transform

  • Loading branch information...
commit 83173b960ea7eb2b24d573f326be59948df33536 1 parent 3b18d9f
@akaariai akaariai authored
View
2  django/db/models/__init__.py
@@ -17,7 +17,7 @@
from django.db.models.fields.proxy import OrderWrt # NOQA
from django.db.models.deletion import ( # NOQA
CASCADE, PROTECT, SET, SET_NULL, SET_DEFAULT, DO_NOTHING, ProtectedError)
-from django.db.models.lookups import Lookup, Extract # NOQA
+from django.db.models.lookups import Lookup, Transform # NOQA
from django.db.models import signals # NOQA
View
2  django/db/models/lookups.py
@@ -39,7 +39,7 @@ def _unregister_lookup(cls, lookup):
del cls.class_lookups[lookup.lookup_name]
-class Extract(RegisterLookupMixin):
+class Transform(RegisterLookupMixin):
def __init__(self, lhs, lookups):
self.lhs = lhs
self.init_lookups = lookups[:]
View
4 django/db/models/sql/query.py
@@ -19,7 +19,7 @@
from django.db.models.aggregates import refs_aggregate
from django.db.models.expressions import ExpressionNode
from django.db.models.fields import FieldDoesNotExist
-from django.db.models.lookups import Extract
+from django.db.models.lookups import Transform
from django.db.models.query_utils import Q
from django.db.models.related import PathInfo
from django.db.models.sql import aggregates as base_aggregates_module
@@ -1092,7 +1092,7 @@ def build_lookup(self, lookups, lhs, rhs):
if next:
if len(lookups) == 1:
# This was the last lookup, so return value lookup.
- if issubclass(next, Extract):
+ if issubclass(next, Transform):
lookups.append('exact')
lhs = next(lhs, lookups)
else:
View
14 docs/ref/models/custom_lookups.txt
@@ -99,9 +99,9 @@ or where it did not exceede a certain amount
We will start by writing a ``AbsoluteValue`` transformer. This will use the SQL
function ``ABS()`` to transform the value before comparison::
- from django.db.models import Extract
+ from django.db.models import Transform
- class AbsoluteValue(Extract):
+ class AbsoluteValue(Transform):
lookup_name = 'abs'
def as_sql(self, qn, connection):
@@ -118,19 +118,19 @@ We can now run the queris we had before.
SELECT ... WHERE ABS("experiments"."change") = 27
-By using ``Extract`` instead of ``Lookup`` it means we are able to chain
+By using ``Transform`` instead of ``Lookup`` it means we are able to chain
further lookups afterwards. So
``Experiment.objects.filter(change__abs__lt=27)`` will generate the following
SQL::
SELECT ... WHERE ABS("experiments"."change") < 27
-Subclasses of ``Extract`` usually only operate on the left-hand side of the
+Subclasses of ``Transform`` usually only operate on the left-hand side of the
expression. Further lookups will work on the transformed value. Note that in
this case where there is no other lookup specified, Django interprets
``change__abs=27`` as ``change__abs__exact=27``.
-When looking for which lookups are allowable after the ``Extract`` has been
+When looking for which lookups are allowable after the ``Transform`` has been
applied, Django uses the ``output_type`` attribute. We didn't need to specify
this here as it didn't change, but supposing we were applying ``AbsoluteValue``
to some field which represents a more complex type (for example a point
@@ -222,7 +222,7 @@ The Query Expression API
~~~~~~~~~~~~~~~~~~~~~~~~
A lookup can assume that the lhs responds to the query expression API.
-Currently direct field references, aggregates and ``Extract`` instances respond
+Currently direct field references, aggregates and ``Transform`` instances respond
to this API.
.. method:: as_sql(qn, connection)
@@ -269,7 +269,7 @@ Lookup reference
The ``lhs`` (left-hand side) of a lookup tells us what we are comparing the
rhs to. It is an object which implements the query expression API. This is
- likely to be a field, an aggregate or a subclass of ``Extract``.
+ likely to be a field, an aggregate or a subclass of ``Transform``.
.. attribute:: rhs
Please sign in to comment.
Something went wrong with that request. Please try again.