--
Ticket URL: <https://code.djangoproject.com/ticket/29168>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Maybe looking at
[https://github.com/django/django/blob/master/django/db/models/lookups.py
the built in lookups] would offer a hint.
--
Ticket URL: <https://code.djangoproject.com/ticket/29168#comment:1>
* component: Database layer (models, ORM) => Documentation
--
Ticket URL: <https://code.djangoproject.com/ticket/29168#comment:2>
* status: new => assigned
* owner: nobody => samermi1
Comment:
I will try to fix this one
--
Ticket URL: <https://code.djangoproject.com/ticket/29168#comment:3>
* status: new => closed
* resolution: => invalid
* stage: Accepted => Unreviewed
Comment:
> However the documentation is unclear about how to reference the lhs in
the as_sql method. Users would like to know how to reference the rhs
BEFORE the LIKE and the lhs AFTER the LIKE in the sql query above. The
documentation only shows examples where the lhs comes first and the rhs
last. This would help users create a custom lookup with the sql above.
IMO [https://docs.djangoproject.com/en/dev/howto/custom-lookups/#a-lookup-
example "A lookup example"] makes it really clear, I don't see how we
could make it clearer. You need to swap `lhs` and `rhs`, e.g.:
{{{
class Custom(Lookup):
lookup_name = 'custom'
def as_sql(self, compiler, connection):
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = rhs_params + lhs_params
return '%s LIKE %s||%%' % (rhs, lhs), params
}}}
Closing as invalid.
--
Ticket URL: <https://code.djangoproject.com/ticket/29168#comment:3>