#33501: order_with_respect_to uses incorrect database alias
-------------------------------------+-------------------------------------
     Reporter:  Damian Posener       |                    Owner:  Damian
                                     |  Posener
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Interestingly this means that the code prior to
 8d2dcc47cd7f6069a1fa2c5b67a329cec5846b7e was broken in another way. It use
 to open a transaction against the default database but the following
 chunked updates were performed against whatever `db_for_write`  returned
 afterwards making them non-atomic when performed against the non-default
 database.

 This makes me realize that `bulk_update` doesn't set `self._for_write =
 True` before accessing `self.db` (like all other create and update
 queryset methods do) which means the aforementioned issue is affects this
 function as well so I'll file another issue for it and assign it to
 myself.

 You patch looks great Damian! It'd be even better if you write a test that
 ensures the updates are performed against the right database to prevent
 future regressions. I suggest you `grep` the test directory for
 `override_settings(DATABASE_ROUTERS` to get an idea of how you can route
 queries to the `other` test database and use
 `assertNumQueries(using='other')` to ensure it was properly routed.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33501#comment:3>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1987e61e43bb3981f9658ac3c8ea3e5b%40djangoproject.com.

Reply via email to