Ticket #19441: 19441-2.diff

File 19441-2.diff, 1.7 KB (added by Claude Paroz, 12 years ago)
  • django/db/backends/postgresql_psycopg2/creation.py

    diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py
    index 90304aa..88afd5f 100644
    a b class DatabaseCreation(BaseDatabaseCreation):  
    4242
    4343    def sql_indexes_for_field(self, model, f, style):
    4444        output = []
    45         if f.db_index:
     45        if f.db_index or f.unique:
    4646            qn = self.connection.ops.quote_name
    4747            db_table = model._meta.db_table
    4848            tablespace = f.db_tablespace or model._meta.db_tablespace
  • docs/ref/models/fields.txt

    diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
    index a2081e0..c6a23db 100644
    a b field, a :exc:`django.db.IntegrityError` will be raised by the model's  
    272272This option is valid on all field types except :class:`ManyToManyField` and
    273273:class:`FileField`.
    274274
     275Note that when ``unique`` is ``True``, you don't need to specify
     276:attr:`~Field.db_index`, because ``unique`` implies the creation of an index.
     277
    275278``unique_for_date``
    276279-------------------
    277280
  • tests/regressiontests/indexes/models.py

    diff --git a/tests/regressiontests/indexes/models.py b/tests/regressiontests/indexes/models.py
    index 4ab74d2..e38eb00 100644
    a b if connection.vendor == 'postgresql':  
    1717    class IndexedArticle(models.Model):
    1818        headline = models.CharField(max_length=100, db_index=True)
    1919        body = models.TextField(db_index=True)
    20         slug = models.CharField(max_length=40, unique=True, db_index=True)
     20        slug = models.CharField(max_length=40, unique=True)
Back to Top