Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7530 closed (fixed)

Related objects are not None like they should be

Reported by: Bastian Kleineidam <calvin@…> Owned by: mtredinnick
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: UI/UX:

Description

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@…> 6 years ago.

Download all attachments as: .zip

Change History (7)

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

comment:1 Changed 6 years ago by gav

  • milestone set to 1.0 alpha
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design 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 6 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 6 years ago by garcia_marc

  • milestone changed from 1.0 alpha to 1.0

According to ticket organization defined in http://code.djangoproject.com/wiki/VersionOneRoadmap#how-you-can-help 1.0 alpha tickets should be just features in the Must have (http://code.djangoproject.com/wiki/VersionOneRoadmap#must-have-features) list.

As bug, it should be fixed before 1.0 milestone.

comment:4 Changed 6 years ago by mtredinnick

  • Owner changed from nobody to mtredinnick

comment:5 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.