Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25893 closed Cleanup/optimization (fixed)

Custom Lookups & Transform example lhs/rhs swap

Reported by: Bruno Alla Owned by: Bruno Alla
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the doc for lookups and transform, in the example on optimizing lookups:
https://docs.djangoproject.com/en/1.9/howto/custom-lookups/#writing-an-efficient-abs-lt-lookup

The paragraph after the code snippets confused me:

There are a couple of notable things going on. First, AbsoluteValueLessThan isn’t calling process_lhs(). Instead it skips the transformation of the lhs done by AbsoluteValue and uses the original lhs. That is, we want to get 27 not ABS(27)

I initially though that lhs and rhs were swapped, but after asking on the #django IRC channel, I was advised that the confusion come from the last sentence, which should actually refer to the left of the SQL, rather than the right side:

That is, we want to get "experiments"."change" not ABS("experiments"."change")

Happy to submit a PR if suggested solution is accepted.

Change History (6)

comment:1 by Moritz Sichert, 9 years ago

Triage Stage: UnreviewedAccepted
Version: 1.8master

comment:2 by Bruno Alla, 9 years ago

Owner: changed from nobody to Bruno Alla
Status: newassigned

comment:3 by Tim Graham, 9 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In ffcdb0b:

Fixed #25893 -- Corrected custom lookups example.

comment:5 by Tim Graham <timograham@…>, 9 years ago

In 740feb48:

[1.9.x] Fixed #25893 -- Corrected custom lookups example.

Backport of ffcdb0b471d0afc72b42b0a2b0c0c4fb45d7b6b1 from master

comment:6 by Tim Graham <timograham@…>, 9 years ago

In c0c2c7e:

[1.8.x] Fixed #25893 -- Corrected custom lookups example.

Backport of ffcdb0b471d0afc72b42b0a2b0c0c4fb45d7b6b1 from master

Note: See TracTickets for help on using tickets.
Back to Top