Fixed -- Optimized Field.get_col().
get_col() used "self" as "output_field" when it was not given, and
unnecessarily compared "self" to "self".
@@ -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:
+ 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)
- else:
- return self.cached_col
@cached_property
def cached_col(self):
