Re: [Django] #11521: QuerySet.update() doesn't accept fkey assignment by id (with patch)

11 views
Skip to first unread message

Django

unread,
Jun 5, 2013, 7:07:57 AM6/5/13
to django-...@googlegroups.com
#11521: QuerySet.update() doesn't accept fkey assignment by id (with patch)
-------------------------------------+-------------------------------------
Reporter: Adys | Owner: Adys
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* cc: timograham@… (added)
* needs_tests: 1 => 0


Comment:

Added a test:
https://github.com/django/django/pull/1246

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

Django

unread,
Jun 18, 2013, 2:19:01 PM6/18/13
to django-...@googlegroups.com
#11521: QuerySet.update() doesn't accept fkey assignment by id (with patch)
-------------------------------------+-------------------------------------
Reporter: Adys | Owner: Adys
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by akaariai):

As discussed in the pull request the change done to Options.init_name_map
will effectively turn the allow_explicit_fk parameter useless. The change
done is adding field.attname to the name map. The allow_explicit_fk
parameter is used in join generation inside the sql/query.py, and it
allows using attname for lookups when the parameter is set. The parameter
is set for filter() and values() calls at least, but isn't set for some
other operations, like annotate(). I can't see any reason for the
inconsistency - either allow attname everywhere or nowhere.

One test fails if the change to init_name_map and removal of
allow_explicit_fk is done. The failing test is
lookup.tests.LookupTests.test_error_messages, it fails because author_id
is in the error message's "allowed choices" list in addition to author.
But, that is actually correct, author_id is an allowed choice.

Any opposition for making this change at alpha stage? There is a minor
risk this could break something.

The proposed change will also fix this ticket's issue. A patch is
available from: https://github.com/akaariai/django/compare/ticket_11521

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

Django

unread,
Jul 12, 2013, 11:04:44 AM7/12/13
to django-...@googlegroups.com
#11521: QuerySet.update() doesn't accept fkey assignment by id (with patch)
-------------------------------------+-------------------------------------
Reporter: Adys | Owner: Adys
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Accepted => Ready for checkin


Comment:

We can make this change for 1.7. Patch still applies cleanly and tests
pass.

--
Ticket URL: <https://code.djangoproject.com/ticket/11521#comment:9>

Django

unread,
Jul 31, 2013, 8:57:39 AM7/31/13
to django-...@googlegroups.com
#11521: QuerySet.update() doesn't accept fkey assignment by id (with patch)
-------------------------------------+-------------------------------------
Reporter: Adys | Owner: Adys
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Anssi Kääriäinen <akaariai@…>):

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


Comment:

In [changeset:"e01b5a5823fa06a63382f87472978a16c77048d2"]:
{{{
#!CommitTicketReference repository=""
revision="e01b5a5823fa06a63382f87472978a16c77048d2"
Fixed #11521 -- usage of field.attname in .update()

Fixed already by previous patch, only test added.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/11521#comment:10>

Reply all
Reply to author
Forward
0 new messages