Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the contest cloning bug #329

Merged
merged 1 commit into from Sep 19, 2023

Conversation

magnified103
Copy link
Contributor

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.

  • I have explained the purpose of this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the README/documentation
  • Any dependent changes have been merged and published in downstream modules
  • Informed of breaking changes, testing and migrations (if applicable).
  • Attached screenshots (if applicable).

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

As per the Django docs, QuerySets are evaluated lazily. This is crucial, as 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 evaluation.
@hieplpvip hieplpvip merged commit 1a3a38d into VNOI-Admin:master Sep 19, 2023
3 checks passed
@magnified103 magnified103 deleted the contest-clone-fix branch September 19, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants