#24102: BaseDatabaseSchemaEditor.create_model: allow unique_together constraint
name
-------------------------------+--------------------
     Reporter:  dnozay         |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.7
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 In `BaseDatabaseSchemaEditor.create_model` there are currently no names
 for `unique_together` constraints.

 http://stackoverflow.com/a/27836476/1733117

 {{{#!python
 class BaseDatabaseSchemaEditor(object):
     # Overrideable SQL templates
     sql_create_table_unique = "UNIQUE (%(columns)s)"
     sql_create_unique = "ALTER TABLE %(table)s ADD CONSTRAINT %(name)s
 UNIQUE (%(columns)s)"
     sql_delete_unique = "ALTER TABLE %(table)s DROP CONSTRAINT %(name)s"
 }}}

 `create_model` has this bit:
 {{{#!python
         # Add any unique_togethers
         for fields in model._meta.unique_together:
             columns = [model._meta.get_field(field).column for field in
 fields]
             column_sqls.append(self.sql_create_table_unique % {
                 "columns": ", ".join(self.quote_name(column) for column in
 columns),
             })
 }}}

 whereas adding a new unique_together constraint does this:
 {{{#!python
     def _create_unique_sql(self, model, columns):
         return self.sql_create_unique % {
             "table": self.quote_name(model._meta.db_table),
             "name": self.quote_name(self._create_index_name(model,
 columns, suffix="_uniq")),
             "columns": ", ".join(self.quote_name(column) for column in
 columns),
         }
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24102>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.8731202fa0edf763e6327745b41f7565%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to