From 6e4f7ec8540b2c93b2f5bedb3fe5556e0b757494 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 15 Oct 2020 08:17:42 +0200 Subject: [PATCH] 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. --- tests/queryset_pickle/models.py | 1 + tests/queryset_pickle/tests.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/queryset_pickle/models.py b/tests/queryset_pickle/models.py index 905eaeff8e7..689a11f65ec 100644 --- a/tests/queryset_pickle/models.py +++ b/tests/queryset_pickle/models.py @@ -57,6 +57,7 @@ class Container: class M2MModel(models.Model): + added = models.DateField(default=datetime.date.today) groups = models.ManyToManyField(Group) diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index 76a5c332c7f..d0ae963cd9a 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -240,12 +240,12 @@ class PickleabilityTestCase(TestCase): def test_pickle_filteredrelation_m2m(self): group = Group.objects.create(name='group') - m2mmodel = M2MModel.objects.create() + m2mmodel = M2MModel.objects.create(added=datetime.date(2020, 1, 1)) m2mmodel.groups.add(group) groups = Group.objects.annotate( first_m2mmodels=models.FilteredRelation( 'm2mmodel', - condition=models.Q(m2mmodel__pk__lt=10), + condition=models.Q(m2mmodel__added__year=2020), ), ).annotate(count_groups=models.Count('first_m2mmodels__groups')) groups_query = pickle.loads(pickle.dumps(groups.query))