#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/062.4532d56b24d7691fe9242f63a17d6b11%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.