mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #34285 -- Fixed index/slice lookups on filtered aggregates with ArrayField.
Thanks Simon Charette for the review.
This commit is contained in:
committed by
Mariusz Felisiak
parent
4403432b75
commit
ae1fe72e9b
@@ -325,7 +325,9 @@ class IndexTransform(Transform):
|
||||
|
||||
def as_sql(self, compiler, connection):
|
||||
lhs, params = compiler.compile(self.lhs)
|
||||
return "%s[%%s]" % lhs, params + [self.index]
|
||||
if not lhs.endswith("]"):
|
||||
lhs = "(%s)" % lhs
|
||||
return "%s[%%s]" % lhs, (*params, self.index)
|
||||
|
||||
@property
|
||||
def output_field(self):
|
||||
@@ -349,7 +351,9 @@ class SliceTransform(Transform):
|
||||
|
||||
def as_sql(self, compiler, connection):
|
||||
lhs, params = compiler.compile(self.lhs)
|
||||
return "%s[%%s:%%s]" % lhs, params + [self.start, self.end]
|
||||
if not lhs.endswith("]"):
|
||||
lhs = "(%s)" % lhs
|
||||
return "%s[%%s:%%s]" % lhs, (*params, self.start, self.end)
|
||||
|
||||
|
||||
class SliceTransformFactory:
|
||||
|
||||
Reference in New Issue
Block a user