diff options
author | Andrew Godwin <andrew@aeracode.org> | 2013-04-18 17:16:39 +0100 |
---|---|---|
committer | Andrew Godwin <andrew@aeracode.org> | 2013-04-18 17:16:39 +0100 |
commit | 7f3678dc4cd7146c49bac3fb8f5211f647636aa3 (patch) | |
tree | fdd2a60ccd1a9a3162d89f970db44502e35a3b3f /django/db/backends/postgresql_psycopg2/creation.py | |
parent | b62e82365ad56ca930f7abb1d1dbdf9ce5a7c7c3 (diff) | |
parent | 93c1576f17f6c5ee73f94f8de007f3c33010dc81 (diff) | |
download | django-7f3678dc4cd7146c49bac3fb8f5211f647636aa3.tar.gz |
Merge branch 'master' into schema-alteration
Conflicts:
django/db/backends/__init__.py
django/db/backends/mysql/base.py
django/db/backends/oracle/base.py
django/db/backends/oracle/creation.py
django/db/backends/postgresql_psycopg2/base.py
django/db/backends/sqlite3/base.py
django/db/models/fields/related.py
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/creation.py')
-rw-r--r-- | django/db/backends/postgresql_psycopg2/creation.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py index f131d14abe..819dd7a29e 100644 --- a/django/db/backends/postgresql_psycopg2/creation.py +++ b/django/db/backends/postgresql_psycopg2/creation.py @@ -11,6 +11,7 @@ class DatabaseCreation(BaseDatabaseCreation): # If a column type is set to None, it won't be included in the output. data_types = { 'AutoField': 'serial', + 'BinaryField': 'bytea', 'BooleanField': 'boolean', 'CharField': 'varchar(%(max_length)s)', 'CommaSeparatedIntegerField': 'varchar(%(max_length)s)', @@ -46,7 +47,8 @@ class DatabaseCreation(BaseDatabaseCreation): return '' def sql_indexes_for_field(self, model, f, style): - if f.db_index and not f.unique: + output = [] + if f.db_index or f.unique: qn = self.connection.ops.quote_name db_table = model._meta.db_table tablespace = f.db_tablespace or model._meta.db_tablespace @@ -65,7 +67,8 @@ class DatabaseCreation(BaseDatabaseCreation): "(%s%s)" % (style.SQL_FIELD(qn(f.column)), opclass) + "%s;" % tablespace_sql) - output = [get_index_sql('%s_%s' % (db_table, f.column))] + if not f.unique: + output = [get_index_sql('%s_%s' % (db_table, f.column))] # Fields with database column types of `varchar` and `text` need # a second index that specifies their operator class, which is @@ -78,15 +81,4 @@ class DatabaseCreation(BaseDatabaseCreation): elif db_type.startswith('text'): output.append(get_index_sql('%s_%s_like' % (db_table, f.column), ' text_pattern_ops')) - else: - output = [] return output - - def set_autocommit(self): - self._prepare_for_test_db_ddl() - - def _prepare_for_test_db_ddl(self): - """Rollback and close the active transaction.""" - self.connection.connection.rollback() - self.connection.connection.set_isolation_level( - psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) |