Opened 10 years ago
Last modified 10 years ago
#24886 new Cleanup/optimization
Add process_lhs() method for Transform
Description ¶
The Lookup class has two methods, process_rhs() and process_lhs(). Typical usage is:
def as_sql(self, compiler, connection): lhs_sql, lhs_params = self.process_lhs(compiler, connection) rhs_sql, rhs_params = self.process_rhs(compiler, connection) # return the sql
The typical usage for transforms is:
def as_sql(self, compiler, connection): lhs_sql, lhs_params = compiler.compile(self.lhs) # return the sql
I think it could make sense to add process_lhs() to transform base class. This way one could write transforms using the same process_lhs() method that is used for Lookups, too. At least for me it is hard to remember when to use process_lhs() and when to use compiler.compile.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (2)
comment:1 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 10 years ago
Note:
See TracTickets
for help on using tickets.
Could I suggest going the other way and standardising on
compiler.compile
rather thanprocess_X
? I'm not sure how much work process_lhs does in the normal lookups, so it may not be feasible. But I'd like to standardise on the expressions way to ease the gap between them.