mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #31651 -- Made ExpressionWrapper use grouping columns from wrapped expression.
This commit is contained in:
parent
22a59c01c0
commit
df32fd42b8
@ -863,6 +863,9 @@ class ExpressionWrapper(Expression):
|
|||||||
def get_source_expressions(self):
|
def get_source_expressions(self):
|
||||||
return [self.expression]
|
return [self.expression]
|
||||||
|
|
||||||
|
def get_group_by_cols(self, alias=None):
|
||||||
|
return self.expression.get_group_by_cols(alias=alias)
|
||||||
|
|
||||||
def as_sql(self, compiler, connection):
|
def as_sql(self, compiler, connection):
|
||||||
return self.expression.as_sql(compiler, connection)
|
return self.expression.as_sql(compiler, connection)
|
||||||
|
|
||||||
|
@ -1828,3 +1828,13 @@ class CombinableTests(SimpleTestCase):
|
|||||||
def test_reversed_or(self):
|
def test_reversed_or(self):
|
||||||
with self.assertRaisesMessage(NotImplementedError, self.bitwise_msg):
|
with self.assertRaisesMessage(NotImplementedError, self.bitwise_msg):
|
||||||
object() | Combinable()
|
object() | Combinable()
|
||||||
|
|
||||||
|
|
||||||
|
class ExpressionWrapperTests(SimpleTestCase):
|
||||||
|
def test_empty_group_by(self):
|
||||||
|
expr = ExpressionWrapper(Value(3), output_field=IntegerField())
|
||||||
|
self.assertEqual(expr.get_group_by_cols(alias=None), [])
|
||||||
|
|
||||||
|
def test_non_empty_group_by(self):
|
||||||
|
expr = ExpressionWrapper(Lower(Value('f')), output_field=IntegerField())
|
||||||
|
self.assertEqual(expr.get_group_by_cols(alias=None), [expr.expression])
|
||||||
|
Loading…
Reference in New Issue
Block a user