summaryrefslogtreecommitdiff
path: root/django/db/models/fields
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-06-30 04:46:59 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-06-30 04:46:59 +0000
commitf9df4d1435fd3382fdcc06f75c1c8d62bfe78ec6 (patch)
tree1ed84020b3c2111537b7231d4e42a83cba7be776 /django/db/models/fields
parentb0bc8b9dfd6069e53cd73c1d3411f995a05f0a5a (diff)
Make sure we only create the minimum number of table indexes for MySQL.
This patch simplifies a bunch of code for all backends and removes some duplicate index creation for MySQL, in particular (versions 4.x and later). Patch from Nis Jørgensen. Fixed #5671, #5680, #7170, #7186. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7790 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/fields')
-rw-r--r--django/db/models/fields/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index a893c25e63..dc5cb9609c 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -91,7 +91,7 @@ class Field(object):
self.name = name
self.verbose_name = verbose_name
self.primary_key = primary_key
- self.max_length, self.unique = max_length, unique
+ self.max_length, self._unique = max_length, unique
self.blank, self.null = blank, null
# Oracle treats the empty string ('') as null, so coerce the null
# option whenever '' is a possible value.
@@ -168,6 +168,10 @@ class Field(object):
except KeyError:
return None
+ def unique(self):
+ return self._unique or self.primary_key
+ unique = property(unique)
+
def validate_full(self, field_data, all_data):
"""
Returns a list of errors for this field. This is the main interface,