mirror of https://github.com/django/django.git
Refs #31926 -- Made test_pickle_filteredrelation_m2m do not depend on auto-PK.
This caused failures on CockroachDB that use random rather than serial pk values.
This commit is contained in:
parent
220c4d5c05
commit
6e4f7ec854
|
@ -57,6 +57,7 @@ class Container:
|
||||||
|
|
||||||
|
|
||||||
class M2MModel(models.Model):
|
class M2MModel(models.Model):
|
||||||
|
added = models.DateField(default=datetime.date.today)
|
||||||
groups = models.ManyToManyField(Group)
|
groups = models.ManyToManyField(Group)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -240,12 +240,12 @@ class PickleabilityTestCase(TestCase):
|
||||||
|
|
||||||
def test_pickle_filteredrelation_m2m(self):
|
def test_pickle_filteredrelation_m2m(self):
|
||||||
group = Group.objects.create(name='group')
|
group = Group.objects.create(name='group')
|
||||||
m2mmodel = M2MModel.objects.create()
|
m2mmodel = M2MModel.objects.create(added=datetime.date(2020, 1, 1))
|
||||||
m2mmodel.groups.add(group)
|
m2mmodel.groups.add(group)
|
||||||
groups = Group.objects.annotate(
|
groups = Group.objects.annotate(
|
||||||
first_m2mmodels=models.FilteredRelation(
|
first_m2mmodels=models.FilteredRelation(
|
||||||
'm2mmodel',
|
'm2mmodel',
|
||||||
condition=models.Q(m2mmodel__pk__lt=10),
|
condition=models.Q(m2mmodel__added__year=2020),
|
||||||
),
|
),
|
||||||
).annotate(count_groups=models.Count('first_m2mmodels__groups'))
|
).annotate(count_groups=models.Count('first_m2mmodels__groups'))
|
||||||
groups_query = pickle.loads(pickle.dumps(groups.query))
|
groups_query = pickle.loads(pickle.dumps(groups.query))
|
||||||
|
|
Loading…
Reference in New Issue