#36082: db_table does not truncate properly for the non-default database
-------------------------------------+-------------------------------------
     Reporter:  Scott                |                     Type:  Bug
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  5.1                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 When getting db_table for a model, table name is truncated to
 `connection.ops.max_name_length()`. See
 
[https://github.com/django/django/blob/8bee7fa45cd7bfe70b68784314e994e2d193fd70/django/db/models/options.py#L235
 here].

 Since the name length is always calculated using `django.db.connection`,
 it always truncates the table name based on the max length of the default
 database. This causes issues when using multiple databases that have
 different engines. For example, if we were using a SQLite default database
 and a PostgreSQL secondary database, any table name longer than 63
 characters will cause an error to be thrown.

 This could be fixed by taking the minimum length when getting the table
 name. I can put in a PR.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36082>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070194516bec0d-4f33959e-2c24-4d7a-a0cb-82463bfd9631-000000%40eu-central-1.amazonses.com.

Reply via email to