Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#7530 closed (fixed)

Related objects are not None like they should be

Reported by: Bastian Kleineidam <calvin@…> Owned by: Malcolm Tredinnick
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Most likely changeset [7597] from bug #7369 introduced this behaviour.

Related objects that should be None are now object instances with all fields set to None.
I added a fix for that problem and updated the test case of null_fk accordingly.

Attachments (1)

django_related_null_fields_fix.patch (1.4 KB) - added by Bastian Kleineidam <calvin@…> 10 years ago.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Bastian Kleineidam <calvin@…>

comment:1 Changed 10 years ago by George Vilches

milestone: 1.0 alpha
Triage Stage: UnreviewedDesign decision needed

Have you actually checked to see if the ticket/patch references caused this behavior? As I recall, the functionality of the system was the same before and after that ticket (I was annoyed by the behavior you're describing here before I generated that patch), it would create the model with all empty fields, and the patch itself has nothing to do with model creation of the related fields. Be careful when you indicate a specific patch as the fault of something, as it might mislead the triagers/core devs.

That having been said, I agree that it would be preferable to have the behavior you're describing here in general. It will screw up the code of people who are depending on an empty instance of the remote model existing however, so I'm promoting it to DDN as it breaks backwards compatibility. I'm also taking the liberty of marking it as a 1.0, as it's a large enough feature decision that I believe it needs to be handled before we do our public release. I'll give a +0 on it.

comment:2 Changed 10 years ago by Bastian Kleineidam <calvin@…>

IIRC empty instances for remote models did not exist in Django 0.9x. If objects had a NULL value in the database they were mapped to None values in Python, not to object instances with all fields set to None.

So this is a behaviour change from Django 0.9x. I am not sure which changeset caused it (the above changeset number is just a guess) but before the queryset-refactor merge, empty instances were not created, and now they are.

comment:3 Changed 10 years ago by Marc Garcia

milestone: 1.0 alpha1.0

According to ticket organization defined in 1.0 alpha tickets should be just features in the Must have ( list.

As bug, it should be fixed before 1.0 milestone.

comment:4 Changed 10 years ago by Malcolm Tredinnick

Owner: changed from nobody to Malcolm Tredinnick

comment:5 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [8098]) Fixed #7530, #7716 -- When using select_related() and encountering a NULL
related object, populate the attribute correctly. Patch from Bastien Kleineidam.

comment:4 Changed 7 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top