#32653: Issue with multiple database backends sharing a model with a very long 
name
-------------------------------------+-------------------------------------
               Reporter:  Javier     |          Owner:  nobody
  Buzzi                              |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 ''Original discussion can be found here: https://groups.google.com/g
 /django-developers/c/f3Z0AchkdyU/m/q0puWHYOCgAJ''

 I have a model with a really long name think
 `ThisIsAReallyLongModelNameThatIsAlsoVeryOld`. To complicate things
 further I have a Oracle instance with archival data designated with
 connection name `old` and a new postgres instance with the connection name
 `default`.

 Issue i've found is that if i try and call the model
 `ThisIsAReallyLongModelNameThatIsAlsoVeryOld.objects.using('old').count()`
 i get an error saying that the table `APP_THISISAREALLYLONGMODEL5300` does
 not exist, when it should be using `APP_THISISAREALLYLONGMODEL5BD6`
 instead. When postgres is used it works as expected:
 `ThisIsAReallyLongModelNameThatIsAlsoVeryOld.objects.using('default').count()`

 This is because the default connection is used when the model is
 instantiated, and then its used from that moment on.

 
https://github.com/django/django/blob/stable/3.2.x/django/db/models/options.py#L207

 This is an issue that seems to go back to the beginning of Django.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32653>
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/054.bdf8e51d5f70cbefe479b8ebeed7651b%40djangoproject.com.

Reply via email to