mirror of
https://github.com/django/django.git
synced 2025-08-24 12:34:09 +00:00
Fixed #29851 -- Fixed crash of annotations with window expressions in Subquery.
This commit is contained in:
parent
6fe9c45b72
commit
dd8ed64113
2 changed files with 39 additions and 10 deletions
|
@ -1292,14 +1292,14 @@ class WindowFrame(Expression):
|
|||
template = '%(frame_type)s BETWEEN %(start)s AND %(end)s'
|
||||
|
||||
def __init__(self, start=None, end=None):
|
||||
self.start = start
|
||||
self.end = end
|
||||
self.start = Value(start)
|
||||
self.end = Value(end)
|
||||
|
||||
def set_source_expressions(self, exprs):
|
||||
self.start, self.end = exprs
|
||||
|
||||
def get_source_expressions(self):
|
||||
return [Value(self.start), Value(self.end)]
|
||||
return [self.start, self.end]
|
||||
|
||||
def as_sql(self, compiler, connection):
|
||||
connection.ops.check_expression_support(self)
|
||||
|
@ -1317,16 +1317,16 @@ class WindowFrame(Expression):
|
|||
return []
|
||||
|
||||
def __str__(self):
|
||||
if self.start is not None and self.start < 0:
|
||||
start = '%d %s' % (abs(self.start), connection.ops.PRECEDING)
|
||||
elif self.start is not None and self.start == 0:
|
||||
if self.start.value is not None and self.start.value < 0:
|
||||
start = '%d %s' % (abs(self.start.value), connection.ops.PRECEDING)
|
||||
elif self.start.value is not None and self.start.value == 0:
|
||||
start = connection.ops.CURRENT_ROW
|
||||
else:
|
||||
start = connection.ops.UNBOUNDED_PRECEDING
|
||||
|
||||
if self.end is not None and self.end > 0:
|
||||
end = '%d %s' % (self.end, connection.ops.FOLLOWING)
|
||||
elif self.end is not None and self.end == 0:
|
||||
if self.end.value is not None and self.end.value > 0:
|
||||
end = '%d %s' % (self.end.value, connection.ops.FOLLOWING)
|
||||
elif self.end.value is not None and self.end.value == 0:
|
||||
end = connection.ops.CURRENT_ROW
|
||||
else:
|
||||
end = connection.ops.UNBOUNDED_FOLLOWING
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue