summaryrefslogtreecommitdiff
path: root/django/db
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
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')
-rw-r--r--django/db/backends/__init__.py2
-rw-r--r--django/db/backends/mysql/base.py1
-rw-r--r--django/db/backends/mysql_old/base.py1
-rw-r--r--django/db/backends/oracle/base.py1
-rw-r--r--django/db/models/fields/__init__.py6
5 files changed, 5 insertions, 6 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 7a4e46a7d7..36a2339638 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -41,8 +41,6 @@ class BaseDatabaseWrapper(local):
class BaseDatabaseFeatures(object):
allows_group_by_ordinal = True
- allows_unique_and_pk = True
- autoindexes_primary_keys = True
inline_fk_references = True
needs_datetime_string_cast = True
supports_constraints = True
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 23735a023b..cfa6b0e56c 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -60,7 +60,6 @@ server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})')
# TRADITIONAL will automatically cause most warnings to be treated as errors.
class DatabaseFeatures(BaseDatabaseFeatures):
- autoindexes_primary_keys = False
inline_fk_references = False
empty_fetchmany_value = ()
update_can_self_select = False
diff --git a/django/db/backends/mysql_old/base.py b/django/db/backends/mysql_old/base.py
index e57aee6a04..adfa03d569 100644
--- a/django/db/backends/mysql_old/base.py
+++ b/django/db/backends/mysql_old/base.py
@@ -64,7 +64,6 @@ class MysqlDebugWrapper:
return getattr(self.cursor, attr)
class DatabaseFeatures(BaseDatabaseFeatures):
- autoindexes_primary_keys = False
inline_fk_references = False
empty_fetchmany_value = ()
update_can_self_select = False
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 1df6bac069..54517662c1 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -24,7 +24,6 @@ IntegrityError = Database.IntegrityError
class DatabaseFeatures(BaseDatabaseFeatures):
allows_group_by_ordinal = False
- allows_unique_and_pk = False # Suppress UNIQUE/PK for Oracle (ORA-02259)
empty_fetchmany_value = ()
needs_datetime_string_cast = False
supports_tablespaces = True
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,