mirror of https://github.com/django/django.git
Fixed #32840 -- Optimized Field.get_col().
get_col() used "self" as "output_field" when it was not given, and unnecessarily compared "self" to "self". Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
parent
355ecd1416
commit
5013798fe9
|
@ -392,13 +392,13 @@ class Field(RegisterLookupMixin):
|
|||
return []
|
||||
|
||||
def get_col(self, alias, output_field=None):
|
||||
if output_field is None:
|
||||
output_field = self
|
||||
if alias != self.model._meta.db_table or output_field != self:
|
||||
from django.db.models.expressions import Col
|
||||
return Col(alias, self, output_field)
|
||||
else:
|
||||
if (
|
||||
alias == self.model._meta.db_table and
|
||||
(output_field is None or output_field == self)
|
||||
):
|
||||
return self.cached_col
|
||||
from django.db.models.expressions import Col
|
||||
return Col(alias, self, output_field)
|
||||
|
||||
@cached_property
|
||||
def cached_col(self):
|
||||
|
|
Loading…
Reference in New Issue