Opened 4 years ago

Closed 4 years ago

Last modified 4 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: master
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 Changed 4 years ago by Moritz Sichert

Triage Stage: UnreviewedAccepted
Version: 1.8master

comment:2 Changed 4 years ago by Bruno Alla

Owner: changed from nobody to Bruno Alla
Status: newassigned

comment:3 Changed 4 years ago by Tim Graham

Has patch: set

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

Resolution: fixed
Status: assignedclosed

In ffcdb0b:

Fixed #25893 -- Corrected custom lookups example.

comment:5 Changed 4 years ago by Tim Graham <timograham@…>

In 740feb48:

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

Backport of ffcdb0b471d0afc72b42b0a2b0c0c4fb45d7b6b1 from master

comment:6 Changed 4 years ago by Tim Graham <timograham@…>

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