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 []
|
return []
|
||||||
|
|
||||||
def get_col(self, alias, output_field=None):
|
def get_col(self, alias, output_field=None):
|
||||||
if output_field is None:
|
if (
|
||||||
output_field = self
|
alias == self.model._meta.db_table and
|
||||||
if alias != self.model._meta.db_table or output_field != self:
|
(output_field is None or output_field == self)
|
||||||
from django.db.models.expressions import Col
|
):
|
||||||
return Col(alias, self, output_field)
|
|
||||||
else:
|
|
||||||
return self.cached_col
|
return self.cached_col
|
||||||
|
from django.db.models.expressions import Col
|
||||||
|
return Col(alias, self, output_field)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def cached_col(self):
|
def cached_col(self):
|
||||||
|
|
Loading…
Reference in New Issue