[Django] #26179: Remove null assignment check for non-nullable foreign key fields

23 views
Skip to first unread message

Django

unread,
Feb 5, 2016, 9:44:26 AM2/5/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
As raised in #25349 and [https://groups.google.com/d/topic/django-
developers/4UL_FkDXX-w/discussion discussed on django-developers], the
following behavior should be removed:
{{{
>>> obj.fk = None
ValueError('Cannot assign None: "Obj.fk" does not allow null values.)
}}}
(i.e. no more exception if you assign `None` to a non-nullable foreign
key). It applies to `ForwardManyToOneDescriptor` and
`ReverseOneToOneDescriptor`. The change should be documented in the
"backwards-incompatible changes" section of the release notes.

--
Ticket URL: <https://code.djangoproject.com/ticket/26179>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 5, 2016, 11:04:53 AM2/5/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

A partial implementation of this is
[https://github.com/django/django/pull/5658 on a pull request] for #25349.

After this ticket is completed, we'll rebase that pull request and proceed
with that fix.

--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:1>

Django

unread,
Feb 9, 2016, 1:10:39 PM2/9/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:2>

Django

unread,
Feb 9, 2016, 6:15:08 PM2/9/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | ZachLiuGIS
Cleanup/optimization | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ZachLiuGIS):

* owner: nobody => ZachLiuGIS
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:3>

Django

unread,
Feb 10, 2016, 9:37:16 PM2/10/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | ZachLiuGIS
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ZachLiuGIS):

I have made the changes and created the pull request ticket_26179

I removed both value=None check in `ForwardManyToOneDescriptor` and
`ReverseOneToOneDescriptor`.

Because of that, several tests failed because they have assertRaise for
`ValueError`. So I removed those tests.

This is my first time working on Django. So please let me know if there's
anything I can do better:)

Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:4>

Django

unread,
Feb 10, 2016, 9:49:23 PM2/10/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | ZachLiuGIS
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/6115 PR] (please add a link like
this in the future)

You should also check "Has patch" on the ticket so it appears in the
review queue. Since I left some comments for improvement on the pull
request, I'll mark "Patch needs improvement." Please uncheck it after you
update the pull request. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:5>

Django

unread,
Feb 10, 2016, 11:38:26 PM2/10/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | ZachLiuGIS
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ZachLiuGIS):

Thanks for the help. I have updated the pull request (tests for None
allowed) and also the backwards-incompatible changes in 1.10.txt.

will remember to update the ticket going forward.

--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:6>

Django

unread,
Feb 11, 2016, 8:24:29 AM2/11/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | ZachLiuGIS
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:7>

Django

unread,
Feb 11, 2016, 10:09:06 AM2/11/16
to django-...@googlegroups.com
#26179: Remove null assignment check for non-nullable foreign key fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | ZachLiuGIS
Cleanup/optimization | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"04e13c89138d48c20e774a2b6bf06796f73ac0fe" 04e13c8]:
{{{
#!CommitTicketReference repository=""
revision="04e13c89138d48c20e774a2b6bf06796f73ac0fe"
Fixed #26179 -- Removed null assignment check for non-nullable foreign key
fields.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26179#comment:8>

Reply all
Reply to author
Forward
0 new messages