perf: 使用列表推导式替换循环 - 优化group_by性能
This commit is contained in:
@@ -458,10 +458,11 @@ class AggregateQuery:
|
|||||||
if not fields:
|
if not fields:
|
||||||
raise ValueError("至少需要一个分组字段")
|
raise ValueError("至少需要一个分组字段")
|
||||||
|
|
||||||
group_columns = []
|
group_columns = [
|
||||||
for field_name in fields:
|
getattr(self.model, field_name)
|
||||||
if hasattr(self.model, field_name):
|
for field_name in fields
|
||||||
group_columns.append(getattr(self.model, field_name))
|
if hasattr(self.model, field_name)
|
||||||
|
]
|
||||||
|
|
||||||
if not group_columns:
|
if not group_columns:
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user