Fix mass-creation of vouchers on MySQL

This commit is contained in:
Raphael Michel
2022-02-07 15:31:09 +01:00
parent d313e076a2
commit af3006a5bd

View File

@@ -434,7 +434,8 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, AsyncFormView):
def process_batch(batch_vouchers, voucherids):
Voucher.objects.bulk_create(batch_vouchers)
if not connection.features.can_return_rows_from_bulk_insert:
if not connection.features.can_return_rows_from_bulk_insert or True:
batch_vouchers.clear()
batch_vouchers = list(self.request.event.vouchers.filter(code__in=[v.code for v in batch_vouchers]))
log_entries = []
@@ -460,7 +461,7 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, AsyncFormView):
batch_vouchers = []
for code in form.cleaned_data['codes']:
if len(batch_vouchers) > batch_size:
if len(batch_vouchers) >= batch_size:
process_batch(batch_vouchers, voucherids)
obj = modelcopy(form.instance, code=None)