mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #13724: Corrected routing of write queries involving managers.
Previously, if a database request spanned a related object manager, the first manager encountered would cause a request to the router, and this would bind all subsequent queries to the same database returned by the router. Unfortunately, the first router query would be performed using a read request to the router, resulting in bad routing information being used if the subsequent query was actually a write. This change defers the call to the router until the final query is acutally made. It includes a small *BACKWARDS INCOMPATIBILITY* on an edge case - see the release notes for details. Thanks to Paul Collins (@paulcollinsiii) for the excellent debugging work and patch.
This commit is contained in:
parent
12ca312e1b
commit
9595183d03
5 changed files with 303 additions and 24 deletions
|
@ -368,6 +368,20 @@ For apps with migrations, ``allow_migrate`` will now get passed
|
|||
without custom attributes, methods or managers. Make sure your ``allow_migrate``
|
||||
methods are only referring to fields or other items in ``model._meta``.
|
||||
|
||||
Passing ``None`` to ``Manager.db_manager()``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In previous versions of Django, it was possible to use
|
||||
``db_manager(using=None)`` on a model manager instance to obtain a manager
|
||||
instance using default routing behavior, overriding any manually specified
|
||||
database routing. In Django 1.7, a value of ``None`` passed to db_manager will
|
||||
produce a router that *retains* any manually assigned database routing -- the
|
||||
manager will *not* be reset. This was necessary to resolve an inconsistency in
|
||||
the way routing information cascaded over joins. See `Ticket #13724`_ for more
|
||||
details.
|
||||
|
||||
.. _Ticket #13724: https://code.djangoproject.com/ticket/13724
|
||||
|
||||
pytz may be required
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue