Opened 10 years ago
Last modified 8 hours ago
#24886 assigned Cleanup/optimization
Add process_lhs() method for Transform
Reported by: | Anssi Kääriäinen | Owned by: | Samriddha Kumar Tripathi |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Samriddha Kumar Tripathi | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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.
Change History (8)
comment:1 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 10 years ago
comment:3 by , 10 days ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Hi, I’ve been exploring this ticket and would like to try working on it. I noticed it’s been open for a while, so I’ll first check whether the proposed change still applies to the current codebase. I’m still learning the internals, but I’ll start by reviewing how Transform and Lookup handle SQL compilation and see if adding process_lhs() improves consistency. I’ll share any progress or questions here as I go.
comment:4 by , 8 days ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Thanks for the PR. Don't forget to uncheck Patch Needs Improvement on this ticket when tests are passing to signal you're ready for a review.
comment:6 by , 7 days ago
Patch needs improvement: | unset |
---|
comment:7 by , 3 days ago
Patch needs improvement: | set |
---|
comment:8 by , 8 hours ago
Patch needs improvement: | unset |
---|
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.