Changes between Version 2 and Version 3 of Ticket #32653, comment 5
- Timestamp:
- Apr 15, 2021, 3:57:43 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32653, comment 5
v2 v3 1 1 @Mariusz the issue is see with your solution is that it will work from my current case Postgres as `default`, Oracle as `old`. Where Postgres wont change the `db_table` as long as its under 63 chars??? But if we have the inverse, Oracle as `default` and Postgres as `new`; it will break Postgres since the `db_table` would be something like `backends_verylongmodelname1234` and Postgres would want the whole string `backends_verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz`. This is because the `default` connection is used to setup the table names at startup https://github.com/django/django/blob/stable/3.2.x/django/db/models/options.py#L207 . The solution @Simon suggested would work on both cases. 2 3 Ideally, the line `self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())` would be removed, and the aliases that is done in the `SQLCompiler` be moved to the indivial backend, and that way you can cache the table names for later use.