summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/compiler.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 1d426f49b6..49263d5944 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -403,8 +403,13 @@ class SQLCompiler:
)
continue
- ref, *transforms = col.split(LOOKUP_SEP)
- if expr := self.query.annotations.get(ref):
+ if expr := self.query.annotations.get(col):
+ ref = col
+ transforms = []
+ else:
+ ref, *transforms = col.split(LOOKUP_SEP)
+ expr = self.query.annotations.get(ref)
+ if expr:
if self.query.combinator and self.select:
if transforms:
raise NotImplementedError(