Refs #30158 -- Made alias argument required in signature of Expression.get_group_by_cols() subclasses.

Per deprecation timeline.
This commit is contained in:
Mariusz Felisiak 2021-01-07 07:55:06 +01:00
parent d134b0b93e
commit 5e33ec80d1
3 changed files with 6 additions and 38 deletions

View file

@ -1,24 +0,0 @@
from django.db.models import Count, Func
from django.test import SimpleTestCase
from django.utils.deprecation import RemovedInDjango40Warning
from .models import Employee
class MissingAliasFunc(Func):
template = '1'
def get_group_by_cols(self):
return []
class GetGroupByColsTest(SimpleTestCase):
def test_missing_alias(self):
msg = (
'`alias=None` must be added to the signature of '
'expressions.test_deprecation.MissingAliasFunc.get_group_by_cols().'
)
with self.assertRaisesMessage(RemovedInDjango40Warning, msg):
Employee.objects.values(
one=MissingAliasFunc(),
).annotate(cnt=Count('company_ceo_set'))