From 78c32f1caa9cb9b28be2d867aff586a2016122ed Mon Sep 17 00:00:00 2001 From: Vlastimil Zíma Date: Mon, 19 May 2014 18:19:35 +0200 Subject: Fixed #22514 -- Prevented indexes on virtual fields [postgres]. --- django/db/backends/postgresql_psycopg2/creation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django') diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py index 2594ba1d5f..d363faaa82 100644 --- a/django/db/backends/postgresql_psycopg2/creation.py +++ b/django/db/backends/postgresql_psycopg2/creation.py @@ -47,7 +47,8 @@ class DatabaseCreation(BaseDatabaseCreation): def sql_indexes_for_field(self, model, f, style): output = [] - if f.db_index or f.unique: + db_type = f.db_type(connection=self.connection) + if db_type is not None and (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 @@ -73,7 +74,6 @@ class DatabaseCreation(BaseDatabaseCreation): # a second index that specifies their operator class, which is # needed when performing correct LIKE queries outside the # C locale. See #12234. - db_type = f.db_type(connection=self.connection) if db_type.startswith('varchar'): output.append(get_index_sql('%s_%s_like' % (db_table, f.column), ' varchar_pattern_ops')) -- cgit v1.3