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

Contest.is_private and Problem.is_organization_private can desync #2398

Open
kiritofeng opened this issue Jan 2, 2025 · 1 comment
Open

Comments

@kiritofeng
Copy link
Member

Currently Contest.is_private, Contest.is_organization_private, Contest.limit_join_organizations, and Problem.is_organization_private are computed on save_model. However, if all associated Organization or Profile objects is deleted, these booleans will desync.

The booleans will be recomputed on model save, and the probability of this bug occurring naturally are quite low. We could fix this by writing listeners, or we could wait for the site to update to Django 5 and use https://docs.djangoproject.com/en/5.1/ref/models/fields/#generatedfield.

@Ninjaclasher
Copy link
Member

Generated fields might not work here:

The expressions should be deterministic and only reference fields within the model (in the same database table). Generated fields cannot reference other generated fields. Database backends can impose further restrictions.

Many to many fields are stored in a different table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants