Open Bug 1637382 Opened 4 years ago Updated 4 years ago

Extraction test is broken

Categories

(Tree Management :: Treeherder: Data Ingestion, defect)

defect

Tracking

(Not tracked)

People

(Reporter: ekyle, Unassigned)

Details

Attachments

(1 file)

This code used to create an object with the given dates

https://github.com/mozilla/treeherder/blob/master/tests/extract/conftest.py#L154

bcf = ClassifiedFailure.objects.create(
    **{
        "bug_number": 1234567,
        "created": Date("2020-01-17 12:00:00").datetime,
        "modified": Date("2020-01-17 12:00:00").datetime,
    }
)

this no longer happens

The problem appears here, exactly on the self.raw = raw line the objs[0].created and objs[0].modified properties go from the given (January) date to the current (May) date.

https://github.com/django/django/blob/stable/3.0.x/django/db/models/sql/subqueries.py#L181

def insert_values(self, fields, objs, raw=False):
    self.fields = fields
    self.objs = objs
    self.raw = raw

It is interesting that the raw is not a declared property. It makes me assume there is another system that detects when self.raw is assigned False and then updates the objs. There are other threads running, but I was unable to breakpoint them

It appears django has some nifty obfuscation code. Maybe this is the culprit:

pre_save = ModelSignal(providing_args=["instance", "raw", "using", "update_fields"], use_caching=True)

I have traced the problem to pre_save()

https://github.com/django/django/blob/stable/3.0.x/django/db/models/fields/__init__.py#L1343

which is following the rules declared in the migration

https://github.com/mozilla/treeherder/blob/master/treeherder/model/migrations/0001_squashed_0022_modify_bugscache_and_bugjobmap.py#L123

So, the behaviour is correct now, but was wrong before.

Summary: ClassifiedFailure.objects.create now acting different → Extraction test is broken
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: