mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Work around a potential Django bug on MySQL
On MySQL, we observe that the preloaded items are missing everywhere except the first time they occur.
This commit is contained in:
@@ -6,7 +6,7 @@ from django.contrib import messages
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.files import File
|
||||
from django.db import transaction
|
||||
from django.db.models import Count, F, Max, Prefetch, Q
|
||||
from django.db.models import Count, Exists, F, Max, OuterRef, Prefetch, Q
|
||||
from django.forms.models import inlineformset_factory
|
||||
from django.http import (
|
||||
Http404, HttpResponse, HttpResponseBadRequest, HttpResponseRedirect,
|
||||
@@ -644,7 +644,10 @@ class QuotaList(PaginationMixin, ListView):
|
||||
).prefetch_related(
|
||||
Prefetch(
|
||||
"items",
|
||||
queryset=Item.objects.annotate(has_variations=Count('variations'))
|
||||
queryset=Item.objects.annotate(
|
||||
has_variations=Exists(ItemVariation.objects.filter(item=OuterRef('pk')))
|
||||
),
|
||||
to_attr="cached_items"
|
||||
),
|
||||
"variations",
|
||||
"variations__item"
|
||||
|
||||
Reference in New Issue
Block a user