#33501: order_with_respect_to uses incorrect database alias
-------------------------------------+-------------------------------------
               Reporter:  Damian     |          Owner:  nobody
  Posener                            |
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  3.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  1
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 When calling set_RELATED_order on a model that uses order_with_respect_to,
 if a DB router exists that routes that model to a non-default database,
 the routing is ignored, causing a datbase error to occur.

 I've tracked this down to the method_set_order function here:
 https://github.com/django/django/blob/3.2.12/django/db/models/base.py#L2117

 This function updates `using=None` to `using=DEFAULT_DB_ALIAS`, which then
 overrides any database routing set up on the model manager. It should just
 pass through `using=None` so that the manager can deal with determining
 the correct connection to use.

 I believe this got inadvertently broken in #30106 - previously the `using`
 parameter was actually being ignored, but when that got fixed it caused
 this new error. :)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33501>
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/049.f2ff61946a618f0af3415a34b2a83c70%40djangoproject.com.

Reply via email to