From 5bcf13b607ea92c34d13cbb52f70c1e6b76ce5cd Mon Sep 17 00:00:00 2001 From: Boulder Sprinters Date: Tue, 3 Apr 2007 21:59:56 +0000 Subject: [PATCH] boulder-oracle-sprint: Fixed #3743 by not creating another index when the column is a PK and the backend is Oracle. git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4916 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 2 +- django/db/backends/ado_mssql/base.py | 1 + django/db/backends/mysql/base.py | 1 + django/db/backends/oracle/base.py | 1 + django/db/backends/postgresql/base.py | 1 + django/db/backends/postgresql_psycopg2/base.py | 1 + django/db/backends/sqlite3/base.py | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/core/management.py b/django/core/management.py index 4ca4c9f827..bcb4c299de 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -482,7 +482,7 @@ def get_sql_indexes_for_model(model): output = [] for f in model._meta.fields: - if f.db_index: + if f.db_index and not (f.primary_key and backend.autoindexes_primary_keys): unique = f.unique and 'UNIQUE ' or '' output.append( style.SQL_KEYWORD('CREATE %sINDEX' % unique) + ' ' + \ diff --git a/django/db/backends/ado_mssql/base.py b/django/db/backends/ado_mssql/base.py index 6c24912e22..7dc197a3d9 100644 --- a/django/db/backends/ado_mssql/base.py +++ b/django/db/backends/ado_mssql/base.py @@ -90,6 +90,7 @@ class DatabaseWrapper(local): allows_group_by_ordinal = True allows_unique_and_pk = True +autoindexes_primary_keys = False needs_datetime_string_cast = True needs_upper_for_iops = False supports_constraints = True diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 93637e77d4..3928776bb9 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -133,6 +133,7 @@ class DatabaseWrapper(local): allows_group_by_ordinal = True allows_unique_and_pk = True +autoindexes_primary_keys = False needs_datetime_string_cast = True # MySQLdb requires a typecast for dates needs_upper_for_iops = False supports_constraints = True diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index f39701dcd6..1f78df0bf7 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -68,6 +68,7 @@ class DatabaseWrapper(local): allows_group_by_ordinal = False allows_unique_and_pk = False # Suppress UNIQUE/PK for Oracle (ORA-02259) +autoindexes_primary_keys = True needs_datetime_string_cast = False needs_upper_for_iops = True supports_constraints = True diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index e5a7893cc7..05559bd0f0 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -106,6 +106,7 @@ class DatabaseWrapper(local): allows_group_by_ordinal = True allows_unique_and_pk = True +autoindexes_primary_keys = False needs_datetime_string_cast = True needs_upper_for_iops = False supports_constraints = True diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index cc67b306a9..81cee69208 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -74,6 +74,7 @@ class DatabaseWrapper(local): allows_group_by_ordinal = True allows_unique_and_pk = True +autoindexes_primary_keys = False needs_datetime_string_cast = False needs_upper_for_iops = False supports_constraints = True diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 3f5c796843..15f73ae4e7 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -101,6 +101,7 @@ class SQLiteCursorWrapper(Database.Cursor): allows_group_by_ordinal = True allows_unique_and_pk = True +autoindexes_primary_keys = False needs_datetime_string_cast = True needs_upper_for_iops = False supports_constraints = False