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

Many to many relation does not respect softdeletion #1

Open
basask opened this issue Feb 7, 2017 · 0 comments
Open

Many to many relation does not respect softdeletion #1

basask opened this issue Feb 7, 2017 · 0 comments
Labels

Comments

@basask
Copy link
Contributor

basask commented Feb 7, 2017

The problem seems to be in many to many scenarios.
Below a snippet on how to reproduce (untested)

# models
from softdelete.models import SoftDeleteModel

class ModelA(SoftDeleteModel):
    name = models.CharField(max_length=16)

class ModelB(SoftDeleteModel):
    name = models.CharField(max_length=16)

class M2M(SoftDeleteModel):
    left = model.ForeignKey(ModelA, related_name='right')
    right = model.ForeignKey(ModelB, related_name='left')
# test
mA = ModelA.objects.create(name='A')
mB = ModelB.objects.create(name='B')
M2M.objects.create(left=mA, right=mB)

mB.objects.filter(left__left__name='A').count()
# Thats ok. Only one instance found here

M2M.objects.all().delete()

mB.objects.filter(left__left__name='A').count()
# Still finding objects when should be hiding through softdelete
@basask basask added the bug label Feb 7, 2017
@basask basask self-assigned this Feb 10, 2017
@basask basask removed their assignment Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant