mirror of
https://github.com/django/django.git
synced 2025-10-28 16:16:12 +00:00
Fixed #36155 -- Improved error handling when annotate arguments require an alias.
Regression in ed0cbc8d8b.
This commit is contained in:
committed by
Sarah Boyce
parent
b84478ae95
commit
c6ace896a2
@@ -1646,14 +1646,16 @@ class QuerySet(AltersData):
|
||||
)
|
||||
annotations = {}
|
||||
for arg in args:
|
||||
# The default_alias property may raise a TypeError.
|
||||
# The default_alias property raises TypeError if default_alias
|
||||
# can't be set automatically or AttributeError if it isn't an
|
||||
# attribute.
|
||||
try:
|
||||
if arg.default_alias in kwargs:
|
||||
raise ValueError(
|
||||
"The named annotation '%s' conflicts with the "
|
||||
"default name for another annotation." % arg.default_alias
|
||||
)
|
||||
except TypeError:
|
||||
except (TypeError, AttributeError):
|
||||
raise TypeError("Complex annotations require an alias")
|
||||
annotations[arg.default_alias] = arg
|
||||
annotations.update(kwargs)
|
||||
|
||||
Reference in New Issue
Block a user