Opened 12 years ago
Closed 12 years ago
#21865 closed Uncategorized (fixed)
Greater than/Less than symbols incorrect in 1.7 alpha-1 documentation for Custom Lookups
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Documentation | Version: | 1.7-alpha-1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
The documentation for 1.7-alpha-1 gives an example for writing a custom lookup to generate the following SQL:
SELECT .. WHERE "experiments"."change" < 27 AND "experiments"."change" > -27
from django.db.models import Lookup class AbsoluteValueLessThan(Lookup): lookup_name = 'lt' def as_sql(self, qn, connection): lhs, lhs_params = qn.compile(self.lhs.lhs) rhs, rhs_params = self.process_rhs(qn, connection) params = lhs_params + rhs_params + lhs_params + rhs_params return '%s > %s AND %s < -%s' % (lhs, rhs, lhs, rhs), params AbsoluteValue.register_lookup(AbsoluteValueLessThan)
The return statement has the < and > symbols incorrectly reversed to create
"experiments"."change" > 27 AND "experiments"."change" < -27
.
Change History (3)
comment:1 by , 12 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Good catch, thanks.