#32653: Issue with multiple database backends sharing a model with a very long 
name
-------------------------------------+-------------------------------------
     Reporter:  Javier Buzzi         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 This is kind of have some overlap with
 [https://code.djangoproject.com/ticket/6148#comment:165 the solution
 proposed by Anssi] for #6148.

 If `db_table` was a compilable object (it follows the `as_sql(connection,
 compile)` protocol) then the default implementation could be


 {{{#!python
 class Table:
     def __init__(self, name):
         self.name = name

     def __str__(self):
         returns self.name

     def as_sql(self, connection, compiler):
         return connection.quote_name(
             truncate_name(name, connection.ops.max_name_length())
         )
 }}}

 And be used by `Options.contribute_to_class` as

 {{{
 db_table = self.db_table
 if not db_table:
     db_table = "%s_%s" % (self.app_label, self.model_name)
 self.db_table = Table(db_table)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32653#comment:1>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.64fafa99062068626bdad148f50033b5%40djangoproject.com.

Reply via email to