Project

Profile

Help

Issue #4604

closed

Remove duplicates does not work properly if there are multiple repeated content types in the repo

Added by ipanova@redhat.com about 5 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 51
Quarter:

Description

It got manifested in docker plugin.
Snippet code:

    async def run(self):
        """
        The coroutine for this stage.
        Returns:
            The coroutine for this stage.
        """
        async for batch in self.batches():
            rm_q = Q()
            for d_content in batch:
                if isinstance(d_content.content, self.model):
                    unit_q_dict = {
                        field: getattr(d_content.content, field) for field in self.field_names
                    }
                    # Don't remove *this* object if it is already in the repository version.
                    not_this = ~Q(pk=d_content.content.pk)
                    dupe = Q(**unit_q_dict)
                    rm_q |= Q(dupe & not_this)
            queryset_to_unassociate = self.model.objects.filter(rm_q)
            self.new_version.remove_content(queryset_to_unassociate)

            for d_content in batch:
await self.put(d_content)

When we process declarative_content.content in the batch that is different from the model we are supposed to remove the dupes, we end up to have rm_q empty which leads to removal of whole content of the model.


Files

Screenshot from 2019-03-29 15-22-09.png (259 KB) Screenshot from 2019-03-29 15-22-09.png ipanova@redhat.com, 03/29/2019 03:22 PM

Also available in: Atom PDF