VNOI-Admin / OJ

A modern open-source online judge and contest platform system.
https://oj.vnoi.info
GNU Affero General Public License v3.0
154 stars 67 forks source link

Fix the contest cloning bug #329

Closed magnified103 closed 12 months ago

magnified103 commented 12 months ago

Description

Type of change: bug fix

What

Fix the issue that problems are not properly copied to the destination contest when executing a contest cloning.

Why

The assignment of pk to None affects QuerySets that haven't been evaluated yet (not sure if these behaviors are intended). Using list() effectively forces the queries to perform actual db hits (link).

https://docs.djangoproject.com/en/4.2/topics/db/queries/#querysets-are-lazy

The performance impact of these changes is negligible for all practical use cases.

How Has This Been Tested?

Tested on local.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.