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:
Mariusz Felisiak 2020-10-15 08:17:42 +02:00 committed by GitHub
parent 220c4d5c05
commit 6e4f7ec854
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -57,6 +57,7 @@ class Container:
class M2MModel(models.Model):
added = models.DateField(default=datetime.date.today)
groups = models.ManyToManyField(Group)

View File

@ -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))